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

Query and use the repository.branch when defined in spec #393

Merged
merged 7 commits into from
Nov 24, 2020

Conversation

mrnugget
Copy link
Contributor

@mrnugget mrnugget commented Nov 23, 2020

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.)

@mrnugget mrnugget changed the title WIP: query branch Query and use the repository.branch when defined in spec Nov 23, 2020
@mrnugget mrnugget requested a review from a team November 23, 2020 14:56
@mrnugget mrnugget marked this pull request as ready for review November 23, 2020 14:56
@mrnugget mrnugget added this to the Campaigns Sprint 5 milestone Nov 23, 2020
@chrispine
Copy link
Contributor

Thanks for tackling this!

Copy link
Contributor

@LawnGnome LawnGnome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I appreciate the naming symmetry with types and fields in the backend where possible!

type Branch struct {
Name string
Target struct{ OID string }
Target Target
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger roger.

@LawnGnome
Copy link
Contributor

I hit Control-Enter too early, but the one thing that we do need is a changelog!

@mrnugget mrnugget merged commit 6175b96 into main Nov 24, 2020
@mrnugget mrnugget deleted the mrn/query-branches branch November 24, 2020 08:38
scjohns pushed a commit that referenced this pull request Apr 24, 2023
* Query and use the repository.branch when defined in spec

* Remove debug pritning

* Query specific commit and not query branches

* Merge two repository queries

* Fix critical indentation error (and unused type)

* Fix wrong query

* Add changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

campaigns: allow the target branch to be customised
4 participants