Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions codex-rs/apply-patch/src/invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ mod tests {
assert_matches!(
maybe_parse_apply_patch_verified(
&args,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
LOCAL_FS.as_ref(),
/*sandbox*/ None,
)
Expand All @@ -517,7 +517,7 @@ mod tests {
assert_matches!(
maybe_parse_apply_patch_verified(
&args,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
LOCAL_FS.as_ref(),
/*sandbox*/ None,
)
Expand Down Expand Up @@ -752,7 +752,7 @@ PATCH"#,
_ => panic!("Expected a single UpdateFile hunk"),
};

let path_uri = PathUri::from_path(&path).expect("absolute test path");
let path_uri = PathUri::from_host_native_path(&path).expect("absolute test path");
let diff =
unified_diff_from_chunks(&path_uri, chunks, LOCAL_FS.as_ref(), /*sandbox*/ None)
.await
Expand Down Expand Up @@ -792,7 +792,7 @@ PATCH"#,
_ => panic!("Expected a single UpdateFile hunk"),
};

let path_uri = PathUri::from_path(&path).expect("absolute test path");
let path_uri = PathUri::from_host_native_path(&path).expect("absolute test path");
let diff =
unified_diff_from_chunks(&path_uri, chunks, LOCAL_FS.as_ref(), /*sandbox*/ None)
.await
Expand Down Expand Up @@ -832,7 +832,7 @@ PATCH"#,

let result = maybe_parse_apply_patch_verified(
&argv,
&PathUri::from_path(session_dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(session_dir.path()).expect("absolute test path"),
LOCAL_FS.as_ref(),
/*sandbox*/ None,
)
Expand All @@ -844,7 +844,7 @@ PATCH"#,
result,
MaybeApplyPatchVerified::Body(ApplyPatchAction {
changes: HashMap::from([(
PathUri::from_path(session_dir.path().join(relative_path))
PathUri::from_host_native_path(session_dir.path().join(relative_path))
.expect("absolute test path"),
ApplyPatchFileChange::Update {
unified_diff: r#"@@ -1 +1 @@
Expand All @@ -857,7 +857,8 @@ PATCH"#,
},
)]),
patch: argv[1].clone(),
cwd: PathUri::from_path(session_dir.path()).expect("absolute test path"),
cwd: PathUri::from_host_native_path(session_dir.path())
.expect("absolute test path"),
})
);
}
Expand Down Expand Up @@ -887,7 +888,7 @@ PATCH"#,

let result = maybe_parse_apply_patch_verified(
&argv,
&PathUri::from_path(session_dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(session_dir.path()).expect("absolute test path"),
LOCAL_FS.as_ref(),
/*sandbox*/ None,
)
Expand All @@ -902,8 +903,8 @@ PATCH"#,
worktree_dir.as_path()
);

let source_path =
PathUri::from_path(worktree_dir.join(source_name)).expect("absolute test path");
let source_path = PathUri::from_host_native_path(worktree_dir.join(source_name))
.expect("absolute test path");
let change = action
.changes()
.get(&source_path)
Expand All @@ -912,7 +913,8 @@ PATCH"#,
match change {
ApplyPatchFileChange::Update { move_path, .. } => {
let expected_move_path =
PathUri::from_path(worktree_dir.join(dest_name)).expect("absolute test path");
PathUri::from_host_native_path(worktree_dir.join(dest_name))
.expect("absolute test path");
assert_eq!(move_path.as_ref(), Some(&expected_move_path));
}
other => panic!("expected update change, got {other:?}"),
Expand All @@ -923,7 +925,7 @@ PATCH"#,
async fn test_unreadable_destinations_still_verify() {
let session_dir = tempdir().unwrap();
fs::write(session_dir.path().join("binary.dat"), [0xff, 0xfe, 0xfd]).unwrap();
let cwd = PathUri::from_path(session_dir.path()).expect("absolute test path");
let cwd = PathUri::from_host_native_path(session_dir.path()).expect("absolute test path");
let add_argv = vec![
"apply_patch".to_string(),
"*** Begin Patch\n*** Add File: binary.dat\n+text\n*** End Patch".to_string(),
Expand Down Expand Up @@ -966,7 +968,7 @@ PATCH"#,

let result = maybe_parse_apply_patch_verified(
&argv,
&PathUri::from_path(session_dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(session_dir.path()).expect("absolute test path"),
LOCAL_FS.as_ref(),
/*sandbox*/ None,
)
Expand Down
38 changes: 19 additions & 19 deletions codex-rs/apply-patch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ mod tests {
let mut stderr = Vec::new();
apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand All @@ -937,7 +937,7 @@ mod tests {
#[tokio::test]
async fn test_apply_patch_hunks_accept_relative_and_absolute_paths() {
let dir = tempdir().unwrap();
let cwd = PathUri::from_path(dir.path()).expect("absolute test path");
let cwd = PathUri::from_host_native_path(dir.path()).expect("absolute test path");
let relative_add = dir.path().join("relative-add.txt");
let absolute_add = dir.path().join("absolute-add.txt");
let relative_delete = dir.path().join("relative-delete.txt");
Expand Down Expand Up @@ -1016,7 +1016,7 @@ mod tests {
let mut stderr = Vec::new();
apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down Expand Up @@ -1052,7 +1052,7 @@ mod tests {
let mut stderr = Vec::new();
apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down Expand Up @@ -1092,7 +1092,7 @@ mod tests {
let mut stderr = Vec::new();
apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down Expand Up @@ -1136,7 +1136,7 @@ mod tests {
let mut stderr = Vec::new();
let failure = apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down Expand Up @@ -1196,7 +1196,7 @@ mod tests {
let mut stderr = Vec::new();
apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down Expand Up @@ -1254,7 +1254,7 @@ mod tests {
let mut stderr = Vec::new();
apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down Expand Up @@ -1298,7 +1298,7 @@ mod tests {
let mut stderr = Vec::new();
apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down Expand Up @@ -1341,7 +1341,7 @@ mod tests {
let mut stderr = Vec::new();
apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down Expand Up @@ -1391,7 +1391,7 @@ mod tests {
[Hunk::UpdateFile { chunks, .. }] => chunks,
_ => panic!("Expected a single UpdateFile hunk"),
};
let path_uri = PathUri::from_path(&path).expect("absolute test path");
let path_uri = PathUri::from_host_native_path(&path).expect("absolute test path");
let diff = unified_diff_from_chunks(
&path_uri,
update_file_chunks,
Expand Down Expand Up @@ -1439,7 +1439,7 @@ mod tests {
_ => panic!("Expected a single UpdateFile hunk"),
};

let resolved_path = PathUri::from_path(&path).expect("absolute test path");
let resolved_path = PathUri::from_host_native_path(&path).expect("absolute test path");
let diff = unified_diff_from_chunks(
&resolved_path,
chunks,
Expand Down Expand Up @@ -1485,7 +1485,7 @@ mod tests {
_ => panic!("Expected a single UpdateFile hunk"),
};

let resolved_path = PathUri::from_path(&path).expect("absolute test path");
let resolved_path = PathUri::from_host_native_path(&path).expect("absolute test path");
let diff = unified_diff_from_chunks(
&resolved_path,
chunks,
Expand Down Expand Up @@ -1529,7 +1529,7 @@ mod tests {
_ => panic!("Expected a single UpdateFile hunk"),
};

let path_uri = PathUri::from_path(&path).expect("absolute test path");
let path_uri = PathUri::from_host_native_path(&path).expect("absolute test path");
let diff =
unified_diff_from_chunks(&path_uri, chunks, LOCAL_FS.as_ref(), /*sandbox*/ None)
.await
Expand Down Expand Up @@ -1580,7 +1580,7 @@ mod tests {
_ => panic!("Expected a single UpdateFile hunk"),
};

let path_uri = PathUri::from_path(&path).expect("absolute test path");
let path_uri = PathUri::from_host_native_path(&path).expect("absolute test path");
let diff =
unified_diff_from_chunks(&path_uri, chunks, LOCAL_FS.as_ref(), /*sandbox*/ None)
.await
Expand Down Expand Up @@ -1610,7 +1610,7 @@ mod tests {
let mut stderr = Vec::new();
apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down Expand Up @@ -1648,7 +1648,7 @@ g
let mut stderr = Vec::new();
let result = apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand All @@ -1667,7 +1667,7 @@ g
let dir = tempdir().unwrap();
let path = dir.path().join("binary.dat");
fs::write(dir.path().join("source.txt"), "before\n").unwrap();
let cwd = PathUri::from_path(dir.path()).expect("absolute test path");
let cwd = PathUri::from_host_native_path(dir.path()).expect("absolute test path");

for patch in [
wrap_patch("*** Add File: binary.dat\n+text"),
Expand Down Expand Up @@ -1705,7 +1705,7 @@ g
let mut stderr = Vec::new();
let delta = apply_patch(
&patch,
&PathUri::from_path(dir.path()).expect("absolute test path"),
&PathUri::from_host_native_path(dir.path()).expect("absolute test path"),
&mut stdout,
&mut stderr,
LOCAL_FS.as_ref(),
Expand Down
2 changes: 1 addition & 1 deletion codex-rs/apply-patch/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ fn test_parse_patch_accepts_relative_and_absolute_hunk_paths() {
#[test]
fn test_hunk_resolve_path_accepts_relative_and_absolute_paths() {
let cwd_dir = tempfile::tempdir().unwrap();
let cwd = PathUri::from_path(cwd_dir.path()).unwrap();
let cwd = PathUri::from_host_native_path(cwd_dir.path()).unwrap();
let absolute_dir = tempfile::tempdir().unwrap();
let absolute_add = absolute_dir.path().join("absolute-add.py").abs();
let absolute_delete = absolute_dir.path().join("absolute-delete.py").abs();
Expand Down
2 changes: 1 addition & 1 deletion codex-rs/core/src/apply_patch_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tempfile::tempdir;
fn convert_apply_patch_maps_add_variant() {
let tmp = tempdir().expect("tmp");
let path = tmp.path().join("a.txt");
let path_uri = PathUri::from_path(&path).expect("absolute test path");
let path_uri = PathUri::from_host_native_path(&path).expect("absolute test path");
let action = ApplyPatchAction::new_add_for_test(&path_uri, "hello".to_string());

let got = convert_apply_patch_to_protocol(&action);
Expand Down
6 changes: 3 additions & 3 deletions codex-rs/core/src/tools/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ mod tests {
make_session_and_context_with_dynamic_tools_and_rx(Vec::new()).await;
let tracker = Arc::new(Mutex::new(TurnDiffTracker::new()));
let dir = tempdir().expect("tempdir");
let cwd = PathUri::from_path(dir.path()).expect("absolute cwd");
let cwd = PathUri::from_host_native_path(dir.path()).expect("absolute cwd");
let mut stdout = Vec::new();
let mut stderr = Vec::new();
let delta = codex_apply_patch::apply_patch(
Expand Down Expand Up @@ -729,7 +729,7 @@ mod tests {
make_session_and_context_with_dynamic_tools_and_rx(Vec::new()).await;
let tracker = Arc::new(Mutex::new(TurnDiffTracker::new()));
let dir = tempdir().expect("tempdir");
let cwd = PathUri::from_path(dir.path()).expect("absolute cwd");
let cwd = PathUri::from_host_native_path(dir.path()).expect("absolute cwd");

for patch in [
"*** Begin Patch\n*** Add File: a.txt\n+one\n*** End Patch",
Expand Down Expand Up @@ -782,7 +782,7 @@ mod tests {
make_session_and_context_with_dynamic_tools_and_rx(Vec::new()).await;
let tracker = Arc::new(Mutex::new(TurnDiffTracker::new()));
let dir = tempdir().expect("tempdir");
let cwd = PathUri::from_path(dir.path()).expect("absolute cwd");
let cwd = PathUri::from_host_native_path(dir.path()).expect("absolute cwd");
let mut stdout = Vec::new();
let mut stderr = Vec::new();
let delta = codex_apply_patch::apply_patch(
Expand Down
2 changes: 1 addition & 1 deletion codex-rs/core/src/turn_diff_tracker_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn git_blob_sha1_hex(data: &str) -> String {
}

async fn apply_verified_patch(root: &Path, patch: &str) -> AppliedPatchDelta {
let cwd = PathUri::from_path(root).expect("absolute tempdir path");
let cwd = PathUri::from_host_native_path(root).expect("absolute tempdir path");
let argv = vec!["apply_patch".to_string(), patch.to_string()];
match codex_apply_patch::maybe_parse_apply_patch_verified(
&argv,
Expand Down
8 changes: 4 additions & 4 deletions codex-rs/core/tests/common/test_codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ impl TestCodexHarness {
) -> Result<()> {
let abs_path = self.path_abs(rel);
if let Some(parent) = abs_path.parent() {
let parent_uri = PathUri::from_path(&parent)?;
let parent_uri = PathUri::from_host_native_path(&parent)?;
self.test
.fs()
.create_directory(
Expand All @@ -1008,7 +1008,7 @@ impl TestCodexHarness {
)
.await?;
}
let abs_path_uri = PathUri::from_path(&abs_path)?;
let abs_path_uri = PathUri::from_host_native_path(&abs_path)?;
self.test
.fs()
.write_file(
Expand All @@ -1022,7 +1022,7 @@ impl TestCodexHarness {

pub async fn read_file_text(&self, rel: impl AsRef<Path>) -> Result<String> {
let path = self.path_abs(rel);
let path_uri = PathUri::from_path(&path)?;
let path_uri = PathUri::from_host_native_path(&path)?;
Ok(self
.test
.fs()
Expand All @@ -1032,7 +1032,7 @@ impl TestCodexHarness {

pub async fn create_dir_all(&self, rel: impl AsRef<Path>) -> Result<()> {
let path = self.path_abs(rel);
let path_uri = PathUri::from_path(&path)?;
let path_uri = PathUri::from_host_native_path(&path)?;
self.test
.fs()
.create_directory(
Expand Down
Loading
Loading