Refactor git repository initialization and enhance logging levels

- Updated the `flatten_tree` function in `git.rs` to clarify the repository parameter name.
- Changed logging level from `debug` to `trace` in `finalize_patch_application` for more detailed output.
- Modified the `TestServeSession` initialization to persist git configuration to disk, ensuring user identity is accessible for subsequent operations.

These changes aim to improve code clarity, enhance logging detail, and ensure proper git configuration handling in tests.
This commit is contained in:
Joe 2026-03-01 17:09:35 -06:00
parent f24e991aca
commit a506b97e71
4 changed files with 28 additions and 21 deletions

View file

@ -202,18 +202,16 @@ impl TestServeSession {
copy_recursive(&source_path, &project_path)
.expect("Couldn't copy project to temporary directory");
// Initialize git repo and run setup callback
let mut repo = gix::init(&project_path).expect("gix init failed");
{
let mut config = repo.config_snapshot_mut();
config
.set_raw_value(&gix::config::tree::User::NAME, "Test")
.unwrap();
config
.set_raw_value(&gix::config::tree::User::EMAIL, "test@test.com")
.unwrap();
let _ = config.commit_auto_rollback().unwrap();
}
// Initialize git repo and persist config to disk so that
// git_add_all_and_commit (which opens a fresh gix handle via
// gix::discover) can read user identity. The gix SnapshotMut
// API is in-memory only and never writes to .git/config.
gix::init(&project_path).expect("gix init failed");
fs::write(
project_path.join(".git/config"),
"[user]\n\tname = Test\n\temail = test@test.com\n[core]\n\tautocrlf = false\n",
)
.expect("Failed to write .git/config");
setup(&project_path);