Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(query): add filter to affectedPackages #9201

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions crates/turborepo-lib/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ impl RepositoryQuery {
&self,
base: Option<String>,
head: Option<String>,
filter: Option<PackagePredicate>,
) -> Result<Array<Package>, Error> {
let mut opts = self.run.opts().clone();
opts.scope_opts.affected_range = Some((base, head));
Expand All @@ -304,6 +305,7 @@ impl RepositoryQuery {
run: self.run.clone(),
name: package,
})
.filter(|package| filter.as_ref().map_or(true, |f| f.check(package)))
.sorted_by(|a, b| a.name.cmp(&b.name))
.collect())
}
Expand Down
17 changes: 17 additions & 0 deletions turborepo-tests/integration/tests/affected.t
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,21 @@ Do the same thing with the `query` command
]
}
}
}

Use a filter with `affectedPackages`
$ ${TURBO} query "query { affectedPackages(filter: { equal: { field: NAME, value: \"my-app\" } }) { items { name } } }"
WARNING query command is experimental and may change in the future
WARNING unable to detect git range, assuming all files have changed: git error: fatal: no merge base found

{
"data": {
"affectedPackages": {
"items": [
{
"name": "my-app"
}
]
}
}
}
Loading