more logging/diagnostics when repo cant be opened

This commit is contained in:
extrawurst 2023-08-10 15:39:39 +02:00
parent 53988ba4e0
commit 7400d5bc68
4 changed files with 10 additions and 5 deletions

View file

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* simplify theme overrides [[@cruessler](https://github.com/cruessler)] ([#1367](https://github.com/extrawurst/gitui/issues/1367)) * simplify theme overrides [[@cruessler](https://github.com/cruessler)] ([#1367](https://github.com/extrawurst/gitui/issues/1367))
* support for sign-off of commits [[@domtac](https://github.com/domtac)]([#1757](https://github.com/extrawurst/gitui/issues/1757)) * support for sign-off of commits [[@domtac](https://github.com/domtac)]([#1757](https://github.com/extrawurst/gitui/issues/1757))
* switched from textwrap to bwrap for text wrapping [[@TheBlackSheep3](https://github.com/TheBlackSheep3/)] ([#1762](https://github.com/extrawurst/gitui/issues/1762)) * switched from textwrap to bwrap for text wrapping [[@TheBlackSheep3](https://github.com/TheBlackSheep3/)] ([#1762](https://github.com/extrawurst/gitui/issues/1762))
* more logging diagnostics when a repo cannot be opened
### Fixes ### Fixes
* fix commit dialog char count for multibyte characters ([#1726](https://github.com/extrawurst/gitui/issues/1726)) * fix commit dialog char count for multibyte characters ([#1726](https://github.com/extrawurst/gitui/issues/1726))

View file

@ -94,8 +94,8 @@ pub use tags::{
}; };
pub use tree::{tree_file_content, tree_files, TreeFile}; pub use tree::{tree_file_content, tree_files, TreeFile};
pub use utils::{ pub use utils::{
get_head, get_head_tuple, is_repo, repo_dir, stage_add_all, get_head, get_head_tuple, repo_dir, repo_open_error,
stage_add_file, stage_addremoved, Head, stage_add_all, stage_add_file, stage_addremoved, Head,
}; };
pub use git2::ResetType; pub use git2::ResetType;

View file

@ -25,13 +25,13 @@ pub struct Head {
} }
/// ///
pub fn is_repo(repo_path: &RepoPath) -> bool { pub fn repo_open_error(repo_path: &RepoPath) -> Option<String> {
Repository::open_ext( Repository::open_ext(
repo_path.gitpath(), repo_path.gitpath(),
RepositoryOpenFlags::empty(), RepositoryOpenFlags::empty(),
Vec::<&Path>::new(), Vec::<&Path>::new(),
) )
.is_ok() .map_or_else(|e| Some(e.to_string()), |_| None)
} }
/// ///

View file

@ -323,7 +323,11 @@ fn draw<B: Backend>(
} }
fn valid_path(repo_path: &RepoPath) -> bool { fn valid_path(repo_path: &RepoPath) -> bool {
asyncgit::sync::is_repo(repo_path) let error = asyncgit::sync::repo_open_error(repo_path);
if let Some(error) = &error {
eprintln!("repo open error: {error}");
}
error.is_none()
} }
fn select_event( fn select_event(