Skip to content

Query and use the repository.branch when defined in spec

Warren Gifford requested to merge mrn/query-branches into main

Created by: mrnugget

This fixes https://github.com/sourcegraph/sourcegraph/issues/15070 by changing the evaluation of the on.repository field in the campaign spec to actually query for and use the branch attribute.

It queries the GraphQL API for a commit that matches the exact rev and returns an error if no commit was found.

If the campaign spec uses repositoriesMatchingQuery and repository, like this

  - repositoriesMatchingQuery: repo:automation-testing
  - repository: github.com/sourcegraph/automation-testing
    branch: thorstens-test-branch

then the second branch, thorstens-test-branch, is checked out and used as the base branch for the changeset.

What we don't support yet is using a revspec in the search query, like repo:github.com/sourcegraph/automation-testing@thorstens-test-branch foobar, and using that to check out the branch. We can tackle that in a separate ticket/PR.

For now, this fixes the original problem and allows users to run the steps for a specified subset of repositories in specific branches.

(Side note: the search results in the template variable ${{ repository.search_result_paths }} are populated by the query, even though they might not match any results in the second branch — that's undefined behaviour for now, but I want to document it in the docs.)

Merge request reports

Loading