From 72e270ef4680d47b5f405a3b1714b6dad47f70df Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Tue, 10 Dec 2024 01:27:29 +0000 Subject: [PATCH 1/2] fix: Configure a fallback git committer for clones and fetches --- src/engines/git.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/engines/git.rs b/src/engines/git.rs index ca0443a..37637d8 100644 --- a/src/engines/git.rs +++ b/src/engines/git.rs @@ -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, + "no name configured during clone", + ) + .expect("works - statically known"); + cfg.set_raw_value( + &gix::config::tree::gitoxide::Committer::EMAIL_FALLBACK, + "noEmailAvailable@example.com", + ) + .expect("works - statically known"); + + Ok(()) + }) + } else { + Ok(()) + } + } + fn update_config(&self, repo: &gix::Repository, mut update: U) -> Result<(), errors::Error> where U: FnMut(&mut gix::config::File<'_>) -> Result<(), errors::Error>, From 461b83352b809f9389fd56891a4758b7445d6133 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Tue, 10 Dec 2024 01:30:51 +0000 Subject: [PATCH 2/2] tweak: Adjust default git commit info for reflog --- src/engines/git.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engines/git.rs b/src/engines/git.rs index 37637d8..0fdd47c 100644 --- a/src/engines/git.rs +++ b/src/engines/git.rs @@ -270,12 +270,12 @@ impl GitEngine { self.update_config(repo, |cfg| { cfg.set_raw_value( &gix::config::tree::gitoxide::Committer::NAME_FALLBACK, - "no name configured during clone", + "github-backup", ) .expect("works - statically known"); cfg.set_raw_value( &gix::config::tree::gitoxide::Committer::EMAIL_FALLBACK, - "noEmailAvailable@example.com", + "github-backup@sierrasoftworks.github.io", ) .expect("works - statically known");