Skip to content

search multiple repos at multiple revisions

Administrator requested to merge rvt/multi-repo-multi-revision into master

Created by: rvantonder

This change allows to specify search queries on multiple repos at multiple revisions. Here is an example syntax:

repo:^github\.com/rvantonder/foo$@some-revision|^github\.com/rvantonder/bar$@other-revision|^github\.com/rvantonder/qux$@final-revision

I briefly checked that one can use commit sha hashes, tag names, and branch names after the @, so this should work. Let me know if there's an issue. The syntax is quite strict so that it minimizes the chance of other conflicting syntax. In particular:

  • Each repo name must be anchored by ^ and $
  • Each repo name must be a constant string, no regex syntax allowed! This is checked and will not work otherwise. Note in the query above that . are escaped, as usual. So, for example, if the . were not escaped, it won't work. If a regex operator like | is used anywhere besides separators for repos, it won't work. If a regex * is used anywhere, it won't work. The behavior will be whatever the search behavior would have done without the changes in this PR.

The above syntax applies only to searching of revisions of different repositories. That is, the following will not work, since multiple revisions are searched in the same repo, and you will get a message saying that it's not possible:

repo:^github\.com/rvantonder/foo$@a-revision-in-repo-foo|^github\.com/rvantonder/foo$@another-revision-in-repo-foo

It is possible to do the above, but with a different syntax and functionality that already exists. To do that, use : to separate the revisions for the same repo:

repo:^github\.com/rvantonder/foo$@a-revision-in-repo-foo:another-revision-in-repo-foo

The : syntax above is an experimental feature so you must enable the following in the site config

  "experimentalFeatures": {
    "searchMultipleRevisionsPerRepository": true
  },

If the above is done, you can use combinations of the syntaxes of | and : to effectively search multiple repos at multiple revisions. I.e., this is fine:

repo:^github\.com/rvantonder/bar@revision|^github\.com/rvantonder/foo$@a-revision-in-repo-foo:another-revision-in-repo-foo

Due to an unrelated part of this change, it is possible that a search for the above will not only include file content results, but may also include name of the matched repos. For example, note the Repository name match results included in this multi-repo-multi-rev search:

Screen Shot 2020-03-31 at 4 38 09 PM

If this is problematic let me know, but that will be some extra effort to avoid.

To reproduce the above screenshot and test that this works:

  • make sure the site config has that experimental feature flag on
  • clone github.com/rvantonder/another-test and github.com/rvantonder/weeeee
  • run the query:
repo:^github\.com/rvantonder/another-test$@revision-contains-b|^github\.com/rvantonder/weeeee$@revision-contains-z:revision-contains-q q|b|z

Merge request reports

Loading