mirror of
https://github.com/openai/codex.git
synced 2026-09-13 11:47:17 +00:00
codex: address PR review feedback (#24540)
This commit is contained in:
@@ -326,14 +326,20 @@ impl<'a> AgentsMdManager<'a> {
|
||||
let mut found: Vec<AbsolutePathBuf> = Vec::new();
|
||||
let candidate_filenames = self.candidate_filenames();
|
||||
for d in search_dirs {
|
||||
let mut candidates = vec![d.join(LOCAL_AGENTS_MD_FILENAME)];
|
||||
let mut candidates = vec![(d.join(LOCAL_AGENTS_MD_FILENAME), false)];
|
||||
if let Some((checkout_root, repo_root)) = linked_checkout_roots.as_ref()
|
||||
&& let Ok(relative) = d.as_path().strip_prefix(checkout_root.as_path())
|
||||
{
|
||||
candidates.push(repo_root.join(relative).join(LOCAL_AGENTS_MD_FILENAME));
|
||||
let inherited = repo_root.join(relative).join(LOCAL_AGENTS_MD_FILENAME);
|
||||
candidates.push((inherited, true));
|
||||
}
|
||||
candidates.extend(candidate_filenames.iter().skip(1).map(|name| d.join(name)));
|
||||
for candidate in candidates {
|
||||
candidates.extend(
|
||||
candidate_filenames
|
||||
.iter()
|
||||
.skip(1)
|
||||
.map(|name| (d.join(name), false)),
|
||||
);
|
||||
for (candidate, is_inherited) in candidates {
|
||||
match fs.get_metadata(&candidate, /*sandbox*/ None).await {
|
||||
Ok(md) if md.is_file => {
|
||||
found.push(candidate);
|
||||
@@ -341,6 +347,7 @@ impl<'a> AgentsMdManager<'a> {
|
||||
}
|
||||
Ok(_) => {}
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => continue,
|
||||
Err(_) if is_inherited => continue,
|
||||
Err(err) => return Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ use core_test_support::PathBufExt;
|
||||
use core_test_support::TempDirExt;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::fs;
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use tempfile::TempDir;
|
||||
@@ -417,6 +419,15 @@ async fn linked_worktrees_inherit_agents_local_md_from_primary_checkout() {
|
||||
get_user_instructions(&cfg).await.as_deref(),
|
||||
Some("primary local")
|
||||
);
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
fs::set_permissions(&repo, fs::Permissions::from_mode(0o000)).unwrap();
|
||||
let instructions = get_user_instructions(&cfg).await;
|
||||
fs::set_permissions(&repo, fs::Permissions::from_mode(0o755)).unwrap();
|
||||
|
||||
assert_eq!(instructions.as_deref(), Some("versioned"));
|
||||
}
|
||||
}
|
||||
|
||||
/// When AGENTS.md is absent but a configured fallback exists, the fallback is used.
|
||||
|
||||
Reference in New Issue
Block a user