Skip to content

a8n: Persist a repository's default branch name along the rev to CampaignJob

Warren Gifford requested to merge a8n/persist-base-ref into master

Created by: mrnugget

This fixes another part of #6625 (closed) where creating pull requests on the code host would fail with the following error message:

ChangesetJob 28: error in GraphQL response: Head sha can't be blank, Base sha can't be blank, No commits between master and sourcegraph/campaign-1, Base ref must be a branch

As it turns out, that was (as we suspected) due to us using "master" as the BaseRef when opening pull requests.

What this PR does it add a new column to CampaignJob, called BaseRef, to which we save the default branch's name, which is the base ref we want to open the pull request against.

Later, when turning CampaignJobs into ChangesetJobs and those into Changesets, we use the CampaignJob.BaseRef instead of "master".

This works nicely, since we're already fetching the default branch and its target commit when constructing CampaignJobs. All we had to do was to persist the branch, too.


Migration: I choose to use master as the value for already existing campaign_jobs in the migration and always fall back to master when a CampaignJob doesn't have a value yet.


With this change I could open a PR against our json-api test repository for the first time! Previously we ran into "could not apply patch" errors there and once that was fixed (see #6625 (closed) for context) we ran into the mentioned error. Now it works.

Merge request reports

Loading