Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ mod tests {
let config_dir = temp.path().join("config");
let workspace = temp.path().join("workspace");
std::fs::create_dir_all(&config_dir).expect("config directory");
std::fs::create_dir_all(workspace.join(".git")).expect("workspace git boundary");
std::fs::create_dir_all(&workspace).expect("workspace directory");
std::fs::write(workspace.join("file.md"), "file\n").expect("file instruction");
std::fs::write(workspace.join("inline.md"), "inline\n").expect("inline instruction");
Expand Down Expand Up @@ -477,6 +478,7 @@ mod tests {
let config_dir = temp.path().join("config");
let workspace = temp.path().join("workspace");
std::fs::create_dir_all(&config_dir).expect("config directory");
std::fs::create_dir_all(workspace.join(".git")).expect("workspace git boundary");
std::fs::create_dir_all(&workspace).expect("workspace directory");
for name in ["legacy.md", "global.md", "shared.md", "project.md"] {
std::fs::write(workspace.join(name), format!("{name}\n")).expect("instruction");
Expand Down Expand Up @@ -573,6 +575,7 @@ mod tests {
let outside = temp.path().join("explicit.md");
std::fs::create_dir_all(&config_dir).expect("config directory");
std::fs::create_dir_all(&home_dir).expect("home directory");
std::fs::create_dir_all(workspace.join(".git")).expect("workspace git boundary");
std::fs::create_dir_all(workspace.join("rules/nested")).expect("rules directory");
std::fs::write(workspace.join("rules/b.md"), "b\n").expect("b rule");
std::fs::write(workspace.join("rules/a.md"), "a\n").expect("a rule");
Expand Down Expand Up @@ -732,6 +735,7 @@ mod tests {
let config_dir = temp.path().join("config");
let workspace = temp.path().join("workspace");
std::fs::create_dir_all(&config_dir).expect("config directory");
std::fs::create_dir_all(workspace.join(".git")).expect("workspace git boundary");
std::fs::create_dir_all(&workspace).expect("workspace directory");
std::fs::write(workspace.join("root.md"), "root\n").expect("root rule");
let mut unrelated = workspace.join("unrelated");
Expand All @@ -758,6 +762,7 @@ mod tests {
let config_dir = temp.path().join("config");
let workspace = temp.path().join("workspace");
std::fs::create_dir_all(&config_dir).expect("config directory");
std::fs::create_dir_all(workspace.join(".git")).expect("workspace git boundary");
std::fs::create_dir_all(workspace.join("team-alpha")).expect("matching directory");
std::fs::write(workspace.join("team-alpha/rule.md"), "matching\n").expect("matching rule");
let unrelated = workspace.join("vendor");
Expand Down Expand Up @@ -785,6 +790,7 @@ mod tests {
let config_dir = temp.path().join("config");
let workspace = temp.path().join("workspace");
std::fs::create_dir_all(&config_dir).expect("config directory");
std::fs::create_dir_all(workspace.join(".git")).expect("workspace git boundary");
std::fs::write(config_dir.join("AGENTS.md"), "global\n").expect("global rule");
let mut too_deep = workspace.join("docs");
for index in 0..33 {
Expand All @@ -810,6 +816,7 @@ mod tests {
let config_dir = temp.path().join("config");
let workspace = temp.path().join("workspace");
std::fs::create_dir_all(&config_dir).expect("config directory");
std::fs::create_dir_all(workspace.join(".git")).expect("workspace git boundary");
std::fs::create_dir_all(&workspace).expect("workspace directory");
for index in 0..257 {
let name = format!("rules/{index:03}.md");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ fn explicit_config_directory_is_appended_to_the_default_global_directory() {
project_config_enabled: false,
});

// Anchor the project boundary at the workspace so the host environment's
// own git repository (e.g. a user home directory that is a git checkout)
// cannot leak into find_project_root and reclassify the explicit global
// directory as workspace-local.
fs::create_dir_all(temp.path().join("workspace/.git")).unwrap();

let snapshot = provider
.discover(&context(temp.path().join("workspace")))
.unwrap();
Expand Down