Skip to content

Commit b6cd5a4

Browse files
Extract signature creation function (#1178)
This will be reused in different places Change: extract-signature-fn
1 parent c6a244d commit b6cd5a4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

josh-proxy/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,18 @@ fn changes_to_refs(
859859
.collect())
860860
}
861861

862+
fn proxy_commit_signature<'a>() -> josh::JoshResult<git2::Signature<'a>> {
863+
Ok(if let Ok(time) = std::env::var("JOSH_COMMIT_TIME") {
864+
git2::Signature::new(
865+
"JOSH",
866+
867+
&git2::Time::new(time.parse()?, 0),
868+
)?
869+
} else {
870+
git2::Signature::now("JOSH", "[email protected]")?
871+
})
872+
}
873+
862874
pub fn merge_meta(
863875
transaction: &josh::cache::Transaction,
864876
transaction_mirror: &josh::cache::Transaction,
@@ -903,16 +915,7 @@ pub fn merge_meta(
903915
tree = josh::filter::tree::insert(transaction.repo(), &tree, path, blob, 0o0100644)?;
904916
}
905917

906-
let signature = if let Ok(time) = std::env::var("JOSH_COMMIT_TIME") {
907-
git2::Signature::new(
908-
"JOSH",
909-
910-
&git2::Time::new(time.parse()?, 0),
911-
)
912-
} else {
913-
git2::Signature::now("JOSH", "[email protected]")
914-
}?;
915-
918+
let signature = proxy_commit_signature()?;
916919
let oid = transaction.repo().commit(
917920
None,
918921
&signature,

0 commit comments

Comments
 (0)