Skip to content

Commit 97cc36c

Browse files
Aaron Hometa-codesync[bot]
authored andcommitted
Fix recursive pattern queries skipping valid directories
Summary: For recursive patterns with Unknown status, we were checking if a BUCK file exists at the prefix path. This incorrectly filtered out valid recursive queries like `fbcode//security/mfgsec/log_collector/...` where the prefix directory exists but has no BUCK file directly. Now we check: - PatternType::Package -> does_package_exist (BUCK file check) - PatternType::Recursive -> does_directory_exist (directory check) Reviewed By: RiskRunner0 Differential Revision: D91609376 fbshipit-source-id: 7f31840d62ad610bfe15d53063a2d6286bf2589c
1 parent 9583007 commit 97cc36c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

td_util/src/buck/run.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use thiserror::Error;
2121
use tracing::info;
2222

2323
use crate::cells::CellInfo;
24+
use crate::types::CellPath;
2425
use crate::types::Package;
2526
use crate::types::ProjectRelativePath;
2627
use crate::types::TargetPattern;
@@ -134,6 +135,14 @@ impl Buck2 {
134135
Ok(false)
135136
}
136137

138+
/// Does a directory exist for recursive queries. Doesn't actually invoke Buck2, but does look at the file system.
139+
pub fn does_directory_exist(&mut self, cells: &CellInfo, x: &Package) -> anyhow::Result<bool> {
140+
let root = self.root()?;
141+
let cell_path = CellPath::new(x.as_str());
142+
let resolved = cells.resolve(&cell_path)?;
143+
Ok(root.join(resolved.as_str()).is_dir())
144+
}
145+
137146
pub fn targets(
138147
&mut self,
139148
extra_args: &[String],

0 commit comments

Comments
 (0)