From 8758f0cd0704ae8294854723048c3a7eb27227b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 17 Oct 2026 12:06:04 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20give=20spawned=20git=20a=20?= =?UTF-8?q?fixed=20identity=20so=20tests=20pass=20on=20clean=20machines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/tests/mirrors_e2e.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/forge-web/tests/mirrors_e2e.rs b/crates/forge-web/tests/mirrors_e2e.rs index 0867698..0cda617 100644 --- a/crates/forge-web/tests/mirrors_e2e.rs +++ b/crates/forge-web/tests/mirrors_e2e.rs @@ -138,6 +138,17 @@ fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) { ); } +/// Fixed identity and config isolation for every git this file spawns, so the result does not +/// depend on the machine's global git config (a clean CI container has none). +const GIT_HERMETIC_ENV: &[(&str, &str)] = &[ + ("GIT_AUTHOR_NAME", "tahinli"), + ("GIT_AUTHOR_EMAIL", "tahinli@example.com"), + ("GIT_COMMITTER_NAME", "tahinli"), + ("GIT_COMMITTER_EMAIL", "tahinli@example.com"), + ("GIT_CONFIG_GLOBAL", "/dev/null"), + ("GIT_CONFIG_NOSYSTEM", "1"), +]; + /// Runs git with credential helpers disabled and extra env. Returns the raw output. fn git_output(cwd: &Path, args: &[&str], env: &[(&str, &str)]) -> Output { let mut cmd = Command::new("git"); @@ -145,7 +156,7 @@ fn git_output(cwd: &Path, args: &[&str], env: &[(&str, &str)]) -> Output { .args(["-c", "credential.helper="]) .args(args) .env("GIT_TERMINAL_PROMPT", "0"); - for (key, value) in env { + for (key, value) in GIT_HERMETIC_ENV.iter().chain(env) { cmd.env(key, value); } cmd.output().expect("run git")