Skip to content

Commit

Permalink
Respect the ignore directive in Buck
Browse files Browse the repository at this point in the history
Summary: We need to respect this when figuring out what has changed (Buck generally doesn't see things marked ignore) and what files are on disk (again, it avoids the ones marked ignore).

Reviewed By: aniketmathur, shayne-fletcher

Differential Revision: D57542263

fbshipit-source-id: bb4c57b86b217cf94d0c56a95b4c5ca69fc65fd7
  • Loading branch information
ndmitchell authored and facebook-github-bot committed Jun 30, 2024
1 parent 227f8c3 commit b4d6b6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions btd/src/buck/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ impl Buck2 {
pub fn does_package_exist(&mut self, cells: &CellInfo, x: &Package) -> anyhow::Result<bool> {
let root = self.root()?;
for build_file in cells.build_files(&x.cell())? {
if root
.join(cells.resolve(&x.join_path(build_file))?.as_str())
.exists()
let cell_path = x.join_path(build_file);
if !cells.is_ignored(&cell_path)
&& root.join(cells.resolve(&cell_path)?.as_str()).exists()
{
return Ok(true);
}
Expand Down
12 changes: 8 additions & 4 deletions btd/src/rerun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,30 @@ pub fn rerun(
return Ok(None);
}

// Files which are ignored by Buck shouldn't be considered going forward,
// but are important to consider for the .buckconfig changes above
let changes = changes.filter_by_cell_path(|x| !cells.is_ignored(x));

let mut res = HashMap::new();
let all_packages = package_set(base);
let add_present = |x: HashSet<_>| x.into_iter().map(|x| (x, PackageStatus::Present));

// targets that are affected due to bzl/build file changes
let (changed, starlark_changes) = rerun_starlark(cells, base, changes)?;
let (changed, starlark_changes) = rerun_starlark(cells, base, &changes)?;
res.extend(add_present(changed));
// targets that are affected due to PACKAGE file changes
res.extend(add_present(rerun_package_file(
changes,
&changes,
&starlark_changes,
&all_packages,
)));
// targets that are affected due to source file changes
res.extend(add_present(rerun_globs(changes, &all_packages)));
res.extend(add_present(rerun_globs(&changes, &all_packages)));

// We extend with this set last, since it may insert PackageStatus::Unknown
// which need to take precedence over the above.
// if build file itself appears or disappears
res.extend(rerun_build_file_existence(cells, changes)?);
res.extend(rerun_build_file_existence(cells, &changes)?);
Ok(Some(res))
}

Expand Down

0 comments on commit b4d6b6d

Please sign in to comment.