radicle: ensure stable sigrefs commit
When updating sigrefs with `storage::refs::save` we weren't checking the `RAD_COMMIT_TIME` variable, so the sigrefs commit was using current time, and we weren't able to reproduce a deterministic sigrefs commit. Make `refs::save` reproducible in debug mode using `debug_assertions` and checking the `RAD_COMMIT_TIME` environment variable. Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
parent
8202495e24
commit
d8711a8d43
|
|
@ -315,6 +315,18 @@ impl SignedRefs<Verified> {
|
||||||
|
|
||||||
let sigref = sigref.with_namespace(remote.into());
|
let sigref = sigref.with_namespace(remote.into());
|
||||||
let author = repo.raw().signature()?;
|
let author = repo.raw().signature()?;
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
let author = if let Ok(s) = std::env::var("RAD_COMMIT_TIME") {
|
||||||
|
// SAFETY: Only used in test code.
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
let timestamp = s.trim().parse::<i64>().unwrap();
|
||||||
|
let time = git2::Time::new(timestamp, 0);
|
||||||
|
git2::Signature::new("radicle", remote.to_string().as_str(), &time)?
|
||||||
|
} else {
|
||||||
|
author
|
||||||
|
};
|
||||||
|
|
||||||
let commit = repo.raw().commit(
|
let commit = repo.raw().commit(
|
||||||
Some(&sigref),
|
Some(&sigref),
|
||||||
&author,
|
&author,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue