Lightweight coding agent that runs in your terminal
Rust
fix git tests (#1747)
Jeremy Rosebe0cd3430053
diff --git a/codex-rs/chatgpt/tests/apply_command_e2e.rs b/codex-rs/chatgpt/tests/apply_command_e2e.rsindex 45c33bedb4..f1a35e1521 100644--- a/codex-rs/chatgpt/tests/apply_command_e2e.rs+++ b/codex-rs/chatgpt/tests/apply_command_e2e.rs@@ -10,8 +10,13 @@ use tokio::process::Command;async fn create_temp_git_repo() -> anyhow::Result<TempDir> {let temp_dir = TempDir::new()?;let repo_path = temp_dir.path();+ let envs = vec![+ ("GIT_CONFIG_GLOBAL", "/dev/null"),+ ("GIT_CONFIG_NOSYSTEM", "1"),+ ];let output = Command::new("git")+ .envs(envs.clone()).args(["init"]).current_dir(repo_path).output()@@ -25,12 +30,14 @@ async fn create_temp_git_repo() -> anyhow::Result<TempDir> {}Command::new("git")+ .envs(envs.clone()).args(["config", "user.email", "[email protected]"]).current_dir(repo_path).output().await?;Command::new("git")+ .envs(envs.clone()).args(["config", "user.name", "Test User"]).current_dir(repo_path).output()@@ -39,12 +46,14 @@ async fn create_temp_git_repo() -> anyhow::Result<TempDir> {std::fs::write(repo_path.join("README.md"), "# Test Repo\n")?;Command::new("git")+ .envs(envs.clone()).args(["add", "README.md"]).current_dir(repo_path).output().await?;let output = Command::new("git")+ .envs(envs.clone()).args(["commit", "-m", "Initial commit"]).current_dir(repo_path).output()diff --git a/codex-rs/core/src/git_info.rs b/codex-rs/core/src/git_info.rsindex cf959d32d1..f5dc016e66 100644--- a/codex-rs/core/src/git_info.rs+++ b/codex-rs/core/src/git_info.rs@@ -111,9 +111,14 @@ mod tests {// Helper function to create a test git repositoryasync fn create_test_git_repo(temp_dir: &TempDir) -> PathBuf {let repo_path = temp_dir.path().to_path_buf();+ let envs = vec![+ ("GIT_CONFIG_GLOBAL", "/dev/null"),+ ("GIT_CONFIG_NOSYSTEM", "1"),+ ];// Initialize git repoCommand::new("git")+ .envs(envs.clone()).args(["init"]).current_dir(&repo_path).output()@@ -122,6 +127,7 @@ mod tests {// Configure git user (required for commits)Command::new("git")+ .envs(envs.clone()).args(["config", "user.name", "Test User"]).current_dir(&repo_path).output()@@ -129,6 +135,7 @@ mod tests {.expect("Failed to set git user name");Command::new("git")+ .envs(envs.clone()).args(["config", "user.email", "[email protected]"]).current_dir(&repo_path).output()@@ -140,6 +147,7 @@ mod tests {fs::write(&test_file, "test content").expect("Failed to write test file");Command::new("git")+ .envs(envs.clone()).args(["add", "."]).current_dir(&repo_path).output()@@ -147,6 +155,7 @@ mod tests {.expect("Failed to add files");Command::new("git")+ .envs(envs.clone()).args(["commit", "-m", "Initial commit"]).current_dir(&repo_path).output()diff --git a/codex-rs/core/tests/cli_stream.rs b/codex-rs/core/tests/cli_stream.rsindex 0ab7bd0bb2..ee0377fc10 100644--- a/codex-rs/core/tests/cli_stream.rs+++ b/codex-rs/core/tests/cli_stream.rs@@ -460,9 +460,14 @@ async fn integration_git_info_unit_test() {// 1. Create temp directory for git repolet temp_dir = TempDir::new().unwrap();let git_repo = temp_dir.path().to_path_buf();+ let envs = vec![+ ("GIT_CONFIG_GLOBAL", "/dev/null"),+ ("GIT_CONFIG_NOSYSTEM", "1"),+ ];// 2. Initialize a git repository with some contentlet init_output = std::process::Command::new("git")+ .envs(envs.clone()).args(["init"]).current_dir(&git_repo).output()@@ -471,12 +476,14 @@ async fn integration_git_info_unit_test() {// Configure git user (required for commits)std::process::Command::new("git")+ .envs(envs.clone()).args(["config", "user.name", "Integration Test"]).current_dir(&git_repo).output().unwrap();std::process::Command::new("git")+ .envs(envs.clone()).args(["config", "user.email", "[email protected]"]).current_dir(&git_repo).output()@@ -487,12 +494,14 @@ async fn integration_git_info_unit_test() {std::fs::write(&test_file, "integration test content").unwrap();std::process::Command::new("git")+ .envs(envs.clone()).args(["add", "."]).current_dir(&git_repo).output().unwrap();let commit_output = std::process::Command::new("git")+ .envs(envs.clone()).args(["commit", "-m", "Integration test commit"]).current_dir(&git_repo).output()@@ -501,6 +510,7 @@ async fn integration_git_info_unit_test() {// Create a branch to test branch detectionstd::process::Command::new("git")+ .envs(envs.clone()).args(["checkout", "-b", "integration-test-branch"]).current_dir(&git_repo).output()@@ -508,6 +518,7 @@ async fn integration_git_info_unit_test() {// Add a remote to test repository URL detectionstd::process::Command::new("git")+ .envs(envs.clone()).args(["remote","add",