-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from SierraSoftworks/feat/committer
fix: Configure a fallback git committer for clones and fetches
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,9 @@ impl GitEngine { | |
"Make sure that your internet connectivity is working correctly, and that your local git configuration is able to clone this repo.", | ||
e))?; | ||
|
||
trace!("Configure fallback committer information"); | ||
self.ensure_committer(&repository)?; | ||
|
||
trace!("Configuring core.bare for Git repository"); | ||
self.update_config(&repository, |c| { | ||
c.set_raw_value(&gix::config::tree::Core::BARE, "true").map_err(|e| errors::system_with_internal( | ||
|
@@ -132,6 +135,8 @@ impl GitEngine { | |
) | ||
})?; | ||
|
||
self.ensure_committer(&repository)?; | ||
|
||
let original_head = repository.head_id().ok(); | ||
|
||
let default_refspecs = vec!["+refs/heads/*:refs/remotes/origin/*".to_string()]; | ||
|
@@ -260,6 +265,27 @@ impl GitEngine { | |
} | ||
} | ||
|
||
fn ensure_committer(&self, repo: &gix::Repository) -> Result<(), errors::Error> { | ||
if repo.committer().is_none() { | ||
self.update_config(repo, |cfg| { | ||
cfg.set_raw_value( | ||
&gix::config::tree::gitoxide::Committer::NAME_FALLBACK, | ||
"github-backup", | ||
) | ||
.expect("works - statically known"); | ||
cfg.set_raw_value( | ||
&gix::config::tree::gitoxide::Committer::EMAIL_FALLBACK, | ||
"[email protected]", | ||
) | ||
.expect("works - statically known"); | ||
|
||
Ok(()) | ||
}) | ||
} else { | ||
Ok(()) | ||
} | ||
} | ||
|
||
fn update_config<U>(&self, repo: &gix::Repository, mut update: U) -> Result<(), errors::Error> | ||
where | ||
U: FnMut(&mut gix::config::File<'_>) -> Result<(), errors::Error>, | ||
|