Skip to content

Commit 7400d5b

Browse files
committed
more logging/diagnostics when repo cant be opened
1 parent 53988ba commit 7400d5b

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
* simplify theme overrides [[@cruessler](https://github.com/cruessler)] ([#1367](https://github.com/extrawurst/gitui/issues/1367))
2121
* support for sign-off of commits [[@domtac](https://github.com/domtac)]([#1757](https://github.com/extrawurst/gitui/issues/1757))
2222
* switched from textwrap to bwrap for text wrapping [[@TheBlackSheep3](https://github.com/TheBlackSheep3/)] ([#1762](https://github.com/extrawurst/gitui/issues/1762))
23+
* more logging diagnostics when a repo cannot be opened
2324

2425
### Fixes
2526
* fix commit dialog char count for multibyte characters ([#1726](https://github.com/extrawurst/gitui/issues/1726))

asyncgit/src/sync/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ pub use tags::{
9494
};
9595
pub use tree::{tree_file_content, tree_files, TreeFile};
9696
pub use utils::{
97-
get_head, get_head_tuple, is_repo, repo_dir, stage_add_all,
98-
stage_add_file, stage_addremoved, Head,
97+
get_head, get_head_tuple, repo_dir, repo_open_error,
98+
stage_add_all, stage_add_file, stage_addremoved, Head,
9999
};
100100

101101
pub use git2::ResetType;

asyncgit/src/sync/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ pub struct Head {
2525
}
2626

2727
///
28-
pub fn is_repo(repo_path: &RepoPath) -> bool {
28+
pub fn repo_open_error(repo_path: &RepoPath) -> Option<String> {
2929
Repository::open_ext(
3030
repo_path.gitpath(),
3131
RepositoryOpenFlags::empty(),
3232
Vec::<&Path>::new(),
3333
)
34-
.is_ok()
34+
.map_or_else(|e| Some(e.to_string()), |_| None)
3535
}
3636

3737
///

src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ fn draw<B: Backend>(
323323
}
324324

325325
fn valid_path(repo_path: &RepoPath) -> bool {
326-
asyncgit::sync::is_repo(repo_path)
326+
let error = asyncgit::sync::repo_open_error(repo_path);
327+
if let Some(error) = &error {
328+
eprintln!("repo open error: {error}");
329+
}
330+
error.is_none()
327331
}
328332

329333
fn select_event(

0 commit comments

Comments
 (0)