Description
Current behavior 😯
When calling Repository::commit_as
, the committer should be valid for changes to the reflog.
commit_as
internally calls out to Repository::edit_references
, which in turn calls Repository::committer
, disregarding the committer given.
In particular, if no committer is configured in the repo (my use case, given I'm calling commit_as
instead of commit
), edit_references
fails to edit the reflog due to a missing committer:
called `Result::unwrap()` on an `Err` value: ReferenceEdit(FileTransactionCommit(CreateOrUpdateRefLog(MissingCommitter)))
Why do I need this
I am using this in some integration tests.
For that reason, it's important to curtail gitoxide
from looking into the local user config (otherwise, tests would be flaky/impossible to run in CI).
The best way I've found (so far) is to clear the config of the repo:
let mut repo: Repository = gix::init(directory: &workdir).unwrap();
let mut config_mut: SnapshotMut<'_> = repo.config_snapshot_mut();
*config = gix::config::File::default();
drop(config_mut);
Expected behavior 🤔
The committer passed into commit_as
is forwarded to edit_references
Git behavior
not applicable
Steps to reproduce 🕹
With version 0.70.0
:
fn main() {
let dir = tempfile::Builder::new()
.prefix("gitoxide-")
.tempdir()
.unwrap();
let workdir = dir.path().join("repo");
let mut repo = gix::init(&workdir).unwrap();
let mut config_mut = repo.config_snapshot_mut();
*config_mut = gix::config::File::default();
drop(config_mut);
let signature = gix::actor::Signature {
name: bstr::BString::from("Someone"),
email: bstr::BString::from("[email protected]"),
time: gix::date::Time::new(0, 0),
};
let blob_oid = repo.write_blob(b"some content").unwrap();
let mut tree_editor = repo
.edit_tree(gix::ObjectId::empty_tree(gix::hash::Kind::default()))
.unwrap();
tree_editor
.upsert("file", gix::object::tree::EntryKind::Blob, blob_oid)
.unwrap();
let tree_id = tree_editor.write().unwrap().detach();
repo.commit_as(
&signature,
&signature,
"refs/heads/master",
"commit",
tree_id,
None::<gix::ObjectId>,
)
.unwrap();
}