impl<'a> TryFrom<git2::Signature<'a>> for Signature {
type Error = crate::Error;
fn try_from(value: git2::Signature<'a>) -> Result<Self, Self::Error> {
let name = std::str::from_utf8(value.name_bytes())?.to_string();
let email = std::str::from_utf8(value.email_bytes())?.to_string();
let timestamp = value.when().seconds();
Ok(Self { name, email, timestamp })
}
}
Looks like Signature only has seconds() part of the timestamp and not the offset (timezone).
AT the same time
pub struct RebaseOperation {
#[napi(js_name = "type")]
/// The type of rebase operation
pub kind: Option<RebaseOperationType>,
/// The commit ID being cherry-picked. This will be populated for all
/// operations except those of type `GIT_REBASE_OPERATION_EXEC`.
pub id: String,
///The executable the user has requested be run. This will only
/// be populated for operations of type `Exec`.
pub exec: Option<String>,
}
requires adding committer info when replaying commits during rebase. This means we can't use original committer Signature since it lacks timezone.
Example in typescript code:
const rebase = repo.rebase(null, repo.getAnnotatedCommit(repo.getCommit(process.argv[2])), null);
let op: RebaseOperation | null;
for (;;) {
op = rebase.next();
if (op === null) break;
const commit = repo.getCommit(op.id);
rebase.commit({
committer: {
name: commit.committer().name,
email: commit.committer().email,
timeOptions: { timestamp: commit.committer().timestamp, offset: 0 }, // No way to get correct offset!
},
});
}
rebase.finish();
Looks like
Signatureonly hasseconds()part of the timestamp and not theoffset(timezone).AT the same time
requires adding committer info when replaying commits during rebase. This means we can't use original committer Signature since it lacks timezone.
Example in typescript code: