Filter out repositories with .batchignore at root#509
Conversation
This implements https://github.com/sourcegraph/sourcegraph/issues/18330 in the simplest possible way by modifying all `repositoriesMatchingQuery` queries to have `-repohasfile:^.batchignore$` in them. Given my instance has the following repositories: - `github.com/sourcegraph-testing/zap` - `github.com/sourcegraph-testing/titan` - `github.com/sourcegraph-testing/tidb` - `github.com/sourcegraph-testing/etcd` - `github.com/sourcegraph-testing/batch-changes-testing-ignore` And I use the following batch spec: ```yaml on: - repositoriesMatchingQuery: repohasfile:README.md repo:sourcegraph-testing steps: - run: echo "a horse says 'hello'" >> README.md container: alpine:3 ``` with this change the `batch-changes-testing-ignore` repository will be ignored: - no archive will be downloaded - no steps executed It's simply filtered out of the search results. But I can manually add it: ```yaml on: - repositoriesMatchingQuery: repohasfile:README.md repo:sourcegraph-testing - repository: github.com/sourcegraph-testing/batch-changes-testing-ignore ```
|
Closing this for now, since I discussed this with @malomarrec on a Zoom call right now. Outcome: we don't want to exclude those repositories from the search results, because we want to print which repositories were ignored. See https://github.com/sourcegraph/sourcegraph/issues/18330#issuecomment-815752987 |
|
Turns out that the functionality we built for monorepo support — a method that returns the locations of a file in a list of repositories — can be used here: instead of adding a screenshot_2021-04-08_15.05.48.mp4 |
LawnGnome
left a comment
There was a problem hiding this comment.
This is surprisingly clean! A real testament to your design work when implementing the file matching in the first place, I think.
This would need documentation and a changelog, of course, but otherwise I think this is good to go.
Co-authored-by: Adam Harvey <aharvey@sourcegraph.com>
This implements https://github.com/sourcegraph/sourcegraph/issues/18330 by querying the locations of `.batchignore` files in each repository yielded by the `on` attribute in a batch spec. If locations were found, the repository is ignored. This can be overwritten by using the `-force-override-ignore` flag. Example: given my instance has the following repositories: - `github.com/sourcegraph-testing/zap` - `github.com/sourcegraph-testing/titan` - `github.com/sourcegraph-testing/tidb` - `github.com/sourcegraph-testing/etcd` - `github.com/sourcegraph-testing/batch-changes-testing-ignore` And I use the following batch spec: ```yaml on: - repositoriesMatchingQuery: repohasfile:README.md repo:sourcegraph-testing steps: - run: echo "a horse says 'hello'" >> README.md container: alpine:3 ``` with this change the `batch-changes-testing-ignore` repository will be ignored: - no archive will be downloaded - no steps executed A message is printed that says it's ignored.
This implements https://github.com/sourcegraph/sourcegraph/issues/18330 by querying the locations of
.batchignorefiles in each repository yielded by theonattribute in a batch spec. If locations were found, the repository is ignored.This can be overwritten by using the
-force-override-ignoreflag.Example: given my instance has the following repositories:
github.com/sourcegraph-testing/zapgithub.com/sourcegraph-testing/titangithub.com/sourcegraph-testing/tidbgithub.com/sourcegraph-testing/etcdgithub.com/sourcegraph-testing/batch-changes-testing-ignoreAnd I use the following batch spec:
with this change the
batch-changes-testing-ignorerepository will be ignored:A message is printed that says it's ignored.