Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Fixed two tests that can fail in some environments that have global git rewrite rules (#7068)

Eric Trautbacdc004be5b
diff --git a/codex-rs/core/src/git_info.rs b/codex-rs/core/src/git_info.rs
index 387e9a682e..34e0afc729 100644
--- a/codex-rs/core/src/git_info.rs
+++ b/codex-rs/core/src/git_info.rs
@@ -825,11 +825,21 @@ mod tests {
.await
.expect("Should collect git info from repo");
+ let remote_url_output = Command::new("git")
+ .args(["remote", "get-url", "origin"])
+ .current_dir(&repo_path)
+ .output()
+ .await
+ .expect("Failed to read remote url");
+ // Some dev environments rewrite remotes (e.g., force SSH), so compare against
+ // whatever URL Git reports instead of a fixed placeholder.
+ let expected_remote = String::from_utf8(remote_url_output.stdout)
+ .unwrap()
+ .trim()
+ .to_string();
+
// Should have repository URL
- assert_eq!(
- git_info.repository_url,
- Some("https://github.com/example/repo.git".to_string())
- );
+ assert_eq!(git_info.repository_url, Some(expected_remote));
}
#[tokio::test]
diff --git a/codex-rs/core/tests/suite/cli_stream.rs b/codex-rs/core/tests/suite/cli_stream.rs
index b484eca22a..d7f0fb9830 100644
--- a/codex-rs/core/tests/suite/cli_stream.rs
+++ b/codex-rs/core/tests/suite/cli_stream.rs
@@ -499,9 +499,20 @@ async fn integration_git_info_unit_test() {
"Git info should contain repository_url"
);
let repo_url = git_info.repository_url.as_ref().unwrap();
+ // Some hosts rewrite remotes (e.g., github.com → [email protected]), so assert against
+ // the actual remote reported by git instead of a static URL.
+ let expected_remote_url = std::process::Command::new("git")
+ .args(["remote", "get-url", "origin"])
+ .current_dir(&git_repo)
+ .output()
+ .unwrap();
+ let expected_remote_url = String::from_utf8(expected_remote_url.stdout)
+ .unwrap()
+ .trim()
+ .to_string();
assert_eq!(
- repo_url, "https://github.com/example/integration-test.git",
- "Repository URL should match what we configured"
+ repo_url, &expected_remote_url,
+ "Repository URL should match git remote get-url output"
);
println!("✅ Git info collection test passed!");