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
6 changes: 4 additions & 2 deletions crates/repo_metadata/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,14 @@ impl Entry {
)
}
/// Builds the materialized tree and standing results during the same filesystem traversal.
#[allow(clippy::too_many_arguments)]
pub(crate) fn build_tree_with_standing_queries(
path: impl Into<PathBuf>,
files: &mut Vec<FileMetadata>,
gitignores: &mut Vec<Gitignore>,
remaining_file_quota: Option<&mut usize>,
options: BuildTreeOptions<'_>,
ancestor_is_ignored: bool,
standing_results: &mut StandingQueryResults,
definitions: &StandingQueryDefinitions,
) -> Result<Self, BuildTreeError> {
Expand All @@ -171,7 +173,7 @@ impl Entry {
gitignores,
remaining_file_quota,
options,
false,
ancestor_is_ignored,
Some(&mut standing_queries),
)
}
Expand Down Expand Up @@ -691,7 +693,7 @@ pub fn is_git_internal_path(path: &Path) -> bool {
/// `force_included_paths`. Each force-included path is a relative component
/// sequence (e.g. `.agents/skills`) matched against the tail of `path`, so a
/// match also holds for the ancestor prefixes leading to it.
fn matches_force_included_path(path: &Path, force_included_paths: &[PathBuf]) -> bool {
pub(crate) fn matches_force_included_path(path: &Path, force_included_paths: &[PathBuf]) -> bool {
let path_components: Vec<_> = path
.components()
.filter_map(|component| match component {
Expand Down
4 changes: 4 additions & 0 deletions crates/repo_metadata/src/entry_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ fn standing_queries_report_skills_below_an_ignored_directory() {
force_included_paths: &[std::path::PathBuf::from(".agents/skills")],
budget_exceeded_behavior: super::BudgetExceededBehavior::StopAndLazyLoad,
},
false,
&mut results,
&definitions,
)
Expand Down Expand Up @@ -448,6 +449,7 @@ fn standing_queries_report_symlinked_skills_without_materializing_symlinked_dire
force_included_paths: &[],
budget_exceeded_behavior: super::BudgetExceededBehavior::StopAndLazyLoad,
},
false,
&mut results,
&definitions,
)
Expand Down Expand Up @@ -491,6 +493,7 @@ fn standing_queries_do_not_report_rules_below_an_unloaded_shallow_directory() {
force_included_paths: &[],
budget_exceeded_behavior: super::BudgetExceededBehavior::StopAndLazyLoad,
},
false,
&mut results,
&StandingQueryDefinitions::default(),
)
Expand Down Expand Up @@ -543,6 +546,7 @@ fn shallow_tree_expands_force_included_skill_branch_only() {
force_included_paths: &[std::path::PathBuf::from(".agents/skills")],
budget_exceeded_behavior: super::BudgetExceededBehavior::StopAndLazyLoad,
},
false,
&mut results,
&definitions,
)
Expand Down
30 changes: 27 additions & 3 deletions crates/repo_metadata/src/local_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ pub struct RepoContents<'a> {
use warp_util::standardized_path::StandardizedPath;

use crate::entry::{
BudgetExceededBehavior, BuildTreeError, BuildTreeOptions, Entry, FileId, IgnoredPathStrategy,
matches_force_included_path, BudgetExceededBehavior, BuildTreeError, BuildTreeOptions, Entry,
FileId, IgnoredPathStrategy,
};
use crate::repository::Repository;
use crate::standing_queries::{
Expand Down Expand Up @@ -929,6 +930,7 @@ impl LocalRepoMetadataModel {
force_included_paths: &self.force_included_paths,
budget_exceeded_behavior: BudgetExceededBehavior::StopAndLazyLoad,
},
false,
&mut standing_results,
&self.standing_query_definitions,
)
Expand Down Expand Up @@ -1187,6 +1189,14 @@ impl LocalRepoMetadataModel {
continue;
}

if is_ignored && !matches_force_included_path(path_to_add, force_included_paths) {
Comment thread
acarl005 marked this conversation as resolved.
mutations.push(FileTreeMutation::AddUnloadedDirectory {
Comment thread
acarl005 marked this conversation as resolved.
path: path_to_add.clone(),
is_ignored,
});
continue;
}

let mut files = Vec::new();
let mut gitignores = gitignores.to_owned();
let mut file_limit = MAX_FILES_PER_REPO;
Expand All @@ -1202,6 +1212,7 @@ impl LocalRepoMetadataModel {
force_included_paths,
budget_exceeded_behavior: BudgetExceededBehavior::StopAndLazyLoad,
},
is_ignored,
&mut standing_results,
standing_query_definitions,
) {
Expand Down Expand Up @@ -1286,7 +1297,9 @@ impl LocalRepoMetadataModel {
let Some(std_path) = StandardizedPath::try_from_local(path).ok() else {
continue;
};
if lazy_load && !Self::is_parent_loaded_in_entry(root_entry, &std_path) {
if (lazy_load || is_ignored)
&& !Self::is_parent_loaded_in_entry(root_entry, &std_path)
{
continue;
}
let Some(parent) = std_path.parent() else {
Expand Down Expand Up @@ -1363,7 +1376,17 @@ impl LocalRepoMetadataModel {
let Some(std_path) = StandardizedPath::try_from_local(path).ok() else {
continue;
};
if lazy_load && !Self::is_parent_loaded_in_entry(root_entry, &std_path) {
if matches!(
root_entry.get(&std_path),
Some(FileTreeEntryState::Directory(dir)) if dir.loaded
) {
continue;
}
// Gitignored placeholders are lazy: like `lazy_load`, don't materialize one
// beneath an unloaded (collapsed) ignored ancestor.
if (lazy_load || is_ignored)
&& !Self::is_parent_loaded_in_entry(root_entry, &std_path)
{
continue;
}
let Some(parent) = std_path.parent() else {
Expand Down Expand Up @@ -1545,6 +1568,7 @@ impl LocalRepoMetadataModel {
force_included_paths: &force_included_paths,
budget_exceeded_behavior: BudgetExceededBehavior::StopAndLazyLoad,
},
false,
&mut standing_results,
&standing_query_definitions,
);
Expand Down
Loading
Loading