Skip to content

a8n: Allow updating individually published Changesets

Administrator requested to merge a8n/update-partial-campaign into master

Created by: mrnugget

This fixes https://github.com/sourcegraph/sourcegraph/issues/7915 with the most straightforward solution:

When updating the CampaignPlan for a Campaign that has been partially published, we only update or close the Changesets/ChangesetJobs that have been published. We don't create new ones.


Example:

An unpublished Campaign with 4 diffs for 4 repositories, where a subset of the Changesets is already published:

ID Repository Diff Published (= ChangesetJob/Changeset created)
1 Repo-A "123" No
2 Repo-B "456" No
3 Repo-C "789" Yes
4 Repo-D "ABC" Yes

(Ignore the syntax of the "Diff", this is just here to illustrate when a diff per repository has changed)

Now we create a new Campaign Plan with 4 diffs for 4 repositories:

ID Repository Diff
5 Repo-A "123"
6 Repo-B "UPDATED"
7 Repo-C "UPDATED"
8 Repo-E "NEWNEW"

When we update the Campaign to have this new Campaign Plan we want the following to happen:

  • The diff for Repo-A should stay as it is
  • The diff for Repo-B should be updated
  • The diff for Repo-C should be updated on the codehost since it's published
  • The diff for Repo-D should be closed on the codehost since it's published and detached from the Campaign
  • The diff for Repo-E should be added to the list but not created on the codehost

So after we update the Campaign to the new CampaignPlan we get this:

ID Repository Diff Published (= ChangesetJob/Changeset created)
4 Repo-A "123" No
5 Repo-B "UPDATED" No
6 Repo-C "UPDATED" Yes
7 Repo-E "NEWNEW" No

And the previously published diff for Repo-D has been closed.


This was actually easier to implement than I thought it would. At least from a code perspective, I had to do a lot of thinking about this. The realization that made it easy to implement:

When we are in "partial update"-mode we can compute the update-diff (which changesets to update, which to create, which to close on the codehosts) as we normally would, **but ignore the list-of-changesets-to-create and only execute the to-update/to-close list)

Merge request reports

Loading