Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 37b0644

Browse files
author
Stephan Dilly
committed
Merge branch 'master' of github.com:Extrawurst/gitui
# Conflicts: # asyncgit/src/sync/utils.rs
2 parents 6d88a67 + 59d43f4 commit 37b0644

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

‎asyncgit/src/sync/utils.rs‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,32 @@ pub fn get_head_repo(repo: &Repository) -> Result<CommitId> {
6666
}
6767
}
6868

69+
/// Wrap Repository::signature to allow unknown user.name.
70+
///
71+
/// See <https://github.com/extrawurst/gitui/issues/79>.
72+
pub fn signature_allow_undefined_name(
73+
repo: &Repository,
74+
) -> std::result::Result<git2::Signature<'static>, git2::Error> {
75+
match repo.signature() {
76+
Err(e) if e.code() == git2::ErrorCode::NotFound => {
77+
let config = repo.config()?;
78+
git2::Signature::now(
79+
config.get_str("user.name").unwrap_or("unknown"),
80+
config.get_str("user.email")?,
81+
)
82+
}
83+
84+
v => v,
85+
}
86+
}
87+
6988
/// this does not run any git hooks
7089
pub fn commit(repo_path: &str, msg: &str) -> Result<CommitId> {
7190
scope_time!("commit");
7291

7392
let repo = repo(repo_path)?;
7493

75-
let signature = repo.signature()?;
94+
let signature = signature_allow_undefined_name(&repo)?;
7695
let mut index = repo.index()?;
7796
let tree_id = index.write_tree()?;
7897
let tree = repo.find_tree(tree_id)?;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /