mirror of
https://github.com/openai/codex.git
synced 2026-11-05 16:29:31 +00:00
Render turn diffs for foreign environment paths (#34654)
## Why Turn diffs need to render paths from remote environments whose path convention may differ from the Codex host. ## What changed - Preserve `PathUri` values through applied patch deltas, display-root discovery, and turn-diff tracking. - Add host-independent relative-path rendering and normalize Windows drive-letter case in `PathUri`. - Render paths relative to each environment's repository root while keeping Git diff headers slash-separated. ## Testing - Cover POSIX, Windows, UNC, encoded-separator, and opaque URI relative paths. - Verify an applied patch in a remote Windows working directory emits a portable unified diff. GitOrigin-RevId: 526f70ae36a40627de5496d375310d12295b69bb
This commit is contained in:
1 parent
9fce9e13fd
commit
1823c13771
11 files changed
+303
-95
No files matched your search
@@ -12,7 +12,6 @@ use codex_exec_server::RemoveOptions;
|
||||
use codex_git_utils::GitInfo;
|
||||
use codex_git_utils::GitSha;
|
||||
use codex_git_utils::collect_git_info;
|
||||
use codex_git_utils::get_git_repo_root_with_fs;
|
||||
use codex_git_utils::get_has_changes;
|
||||
use codex_git_utils::git_diff_to_remote;
|
||||
use codex_git_utils::recent_commits;
|
||||
@@ -602,21 +601,7 @@ async fn resolve_root_git_project_for_trust_returns_none_outside_repo() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn get_git_repo_root_with_fs_detects_gitdir_pointer() {
|
||||
let tmp = TempDir::new().expect("tempdir");
|
||||
let proj = tmp.path().join("proj");
|
||||
let nested = proj.join("nested");
|
||||
std::fs::create_dir_all(&nested).unwrap();
|
||||
std::fs::write(proj.join(".git"), "gitdir: /tmp/fake-worktree\n").unwrap();
|
||||
|
||||
assert_eq!(
|
||||
get_git_repo_root_with_fs(LOCAL_FS.as_ref(), &nested.abs()).await,
|
||||
Some(proj.abs())
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn get_git_repo_root_with_fs_starts_at_parent_for_file() {
|
||||
async fn resolve_root_git_project_for_trust_starts_at_parent_for_file() {
|
||||
let tmp = TempDir::new().expect("tempdir");
|
||||
let proj = tmp.path().join("proj");
|
||||
let nested = proj.join("nested");
|
||||
@@ -626,13 +611,13 @@ async fn get_git_repo_root_with_fs_starts_at_parent_for_file() {
|
||||
std::fs::write(&file, "contents").unwrap();
|
||||
|
||||
assert_eq!(
|
||||
get_git_repo_root_with_fs(LOCAL_FS.as_ref(), &file.abs()).await,
|
||||
resolve_root_git_project_for_trust(LOCAL_FS.as_ref(), &file.abs()).await,
|
||||
Some(proj.abs())
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn get_git_repo_root_with_fs_ignores_metadata_errors() {
|
||||
async fn resolve_root_git_project_for_trust_ignores_metadata_errors() {
|
||||
let tmp = TempDir::new().expect("tempdir");
|
||||
let proj = tmp.path().join("proj");
|
||||
let nested = proj.join("nested");
|
||||
@@ -643,14 +628,14 @@ async fn get_git_repo_root_with_fs_ignores_metadata_errors() {
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
get_git_repo_root_with_fs(&fs, &nested.abs()).await,
|
||||
resolve_root_git_project_for_trust(&fs, &nested.abs()).await,
|
||||
Some(proj.abs())
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[tokio::test]
|
||||
async fn get_git_repo_root_with_fs_supports_windows_namespace_paths() {
|
||||
async fn resolve_root_git_project_for_trust_supports_windows_namespace_paths() {
|
||||
let tmp = TempDir::new().expect("tempdir");
|
||||
let repo = tmp.path().join("repo");
|
||||
std::fs::create_dir_all(repo.join(".git")).unwrap();
|
||||
@@ -660,7 +645,7 @@ async fn get_git_repo_root_with_fs_supports_windows_namespace_paths() {
|
||||
let namespace_nested = namespace_repo.join("nested");
|
||||
|
||||
assert_eq!(
|
||||
get_git_repo_root_with_fs(LOCAL_FS.as_ref(), &namespace_nested.abs()).await,
|
||||
resolve_root_git_project_for_trust(LOCAL_FS.as_ref(), &namespace_nested.abs()).await,
|
||||
Some(namespace_repo.abs())
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user