diff --git a/crates/radicle/src/storage/refs/sigrefs/git.rs b/crates/radicle/src/storage/refs/sigrefs/git.rs index 444ba62f..a64f1b48 100644 --- a/crates/radicle/src/storage/refs/sigrefs/git.rs +++ b/crates/radicle/src/storage/refs/sigrefs/git.rs @@ -21,6 +21,8 @@ pub struct Committer { } impl Committer { + const NAME: &str = "radicle"; + /// Construct a [`Committer`] using the timestamp found at /// [`GIT_COMMITTER_DATE`], /// @@ -64,19 +66,11 @@ impl Committer { } }; - let time = Time::new( - timestamp - .try_into() - .expect("seconds since unix epoch must fit i64"), - 0, - ); - let author = Author { - name: "radicle".to_string(), - email: public_key.to_human(), - time, - }; + let timestamp = timestamp + .try_into() + .expect("seconds since unix epoch must fit i64"); - Self::new(author) + Self::from_key_and_time(public_key, timestamp) } } @@ -88,12 +82,7 @@ impl Committer { /// variable. #[cfg(any(test, feature = "test"))] pub fn stable(public_key: &PublicKey) -> Self { - let author = Author { - name: "radicle".to_string(), - email: public_key.to_human(), - time: Time::new(1671125284, 0), - }; - Self::new(author) + Self::from_key_and_time(public_key, 1671125284) } /// Construct a [`Committer`] with the provided [`Author`]. @@ -104,6 +93,14 @@ impl Committer { pub fn into_inner(self) -> Author { self.author } + + fn from_key_and_time(public_key: &PublicKey, timestamp: i64) -> Self { + Self::new(Author { + name: Self::NAME.to_string(), + email: public_key.to_human(), + time: Time::new(timestamp, 0), + }) + } } mod git2_impls {