mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
Merge remote-tracking branch 'origin/main' into pakrym/core-cwd-absolutepathbuf
# Conflicts: # codex-rs/core/src/tools/runtimes/apply_patch.rs # codex-rs/core/src/tools/runtimes/apply_patch_tests.rs # codex-rs/core/tests/common/lib.rs # codex-rs/tui/src/test_support.rs
This commit is contained in:
@@ -1,37 +1,6 @@
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use std::path::Path;
|
||||
pub(crate) use codex_utils_absolute_path::test_support::PathBufExt;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub(crate) trait PathExt {
|
||||
fn abs(&self) -> AbsolutePathBuf;
|
||||
}
|
||||
|
||||
impl PathExt for Path {
|
||||
fn abs(&self) -> AbsolutePathBuf {
|
||||
if let Ok(path) = AbsolutePathBuf::try_from(self.to_path_buf()) {
|
||||
return path;
|
||||
}
|
||||
if cfg!(windows)
|
||||
&& let Some(path) = self.to_str()
|
||||
&& path.starts_with('/')
|
||||
{
|
||||
return AbsolutePathBuf::try_from(test_path_buf(path))
|
||||
.expect("windows test path should be absolute");
|
||||
}
|
||||
panic!("path should already be absolute");
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait PathBufExt {
|
||||
fn abs(&self) -> AbsolutePathBuf;
|
||||
}
|
||||
|
||||
impl PathBufExt for PathBuf {
|
||||
fn abs(&self) -> AbsolutePathBuf {
|
||||
self.as_path().abs()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn test_path_display(path: &str) -> String {
|
||||
test_path_buf(path).abs().display().to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user