Improve client example test determinism
Collaborative object IDs are derived from their commit oid. These IDs must be reproducible to support testing the client's example. All but one of the parameters used to derive the Object ID is the commit's Author and committer timestamp. Introduce an environment variable 'RAD_COMMIT_TIME' to set both Author and Committer timestamp when creating a commit in the cob module. Use single variable, instead of Git's two (for author and committer), to keep the changes simple. The function being modified returns a single timestamp which is derived from the author's. Signed-off-by: Slack Coder <slackcoder@server.ky>
This commit is contained in:
parent
1f55d7a327
commit
edef49d1ef
|
|
@ -4,3 +4,8 @@
|
|||
// Linking Exception. For full terms see the included LICENSE file.
|
||||
|
||||
pub mod change;
|
||||
|
||||
/// Environment variable to set to overwrite the commit date for both the author and the committer.
|
||||
///
|
||||
/// The format must be a unix timestamp.
|
||||
pub const RAD_COMMIT_TIME: &str = "RAD_COMMIT_TIME";
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use git_ext::Oid;
|
|||
use git_trailers::OwnedTrailer;
|
||||
use nonempty::NonEmpty;
|
||||
|
||||
use crate::git;
|
||||
use crate::history::entry::Timestamp;
|
||||
use crate::{
|
||||
change::{self, store, Change},
|
||||
|
|
@ -235,13 +236,23 @@ where
|
|||
|
||||
{
|
||||
let author = repo.signature()?;
|
||||
let timestamp = author.when().seconds() as Timestamp;
|
||||
let mut timestamp = author.when().seconds();
|
||||
|
||||
let mut headers = commit::Headers::new();
|
||||
headers.push(
|
||||
"gpgsig",
|
||||
&String::from_utf8(crypto::ssh::ExtendedSignature::from(signature).to_armored())?,
|
||||
);
|
||||
let author = commit::Author::try_from(&author)?;
|
||||
let mut author = commit::Author::try_from(&author)?;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
if let Ok(s) = std::env::var(git::RAD_COMMIT_TIME) {
|
||||
if let Ok(v) = s.trim().parse::<i64>() {
|
||||
author.time = git_commit::author::Time::new(v, 0);
|
||||
timestamp = v;
|
||||
}
|
||||
}
|
||||
|
||||
let oid = Commit::new(
|
||||
tree.id(),
|
||||
parents,
|
||||
|
|
@ -253,7 +264,7 @@ where
|
|||
)
|
||||
.write(repo)?;
|
||||
|
||||
Ok((Oid::from(oid), timestamp))
|
||||
Ok((Oid::from(oid), timestamp as u64))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue