a8n: Implement `previewCampaignPlan`
Created by: mrnugget
This is part of https://github.com/sourcegraph/sourcegraph/issues/6085 and implements the GraphQL previewCampaign
mutation.
It validates arguments, creates a CampaignPlan
and multiple CampaignJob
s (one for each repo yielded by the CampaignType
s search query).
The single CampaignType
that's currently implemented is "comby"
, which does search&replace across repositories.
What's in this PR already works: a plan is created, jobs are launched, executed and their Diff
field is updated.
There are a few things missing that I want to address in follow-up PRs in order to make reviewing easier and to unblock @felixfbecker and @eseliger:
-
See comment below
The diff produced by reading json-lines from thereplacer
service is not a valid multi-file diff. While it can be parsed again bydiff.ParseMultiFile
the produced[]*diff.FileDiff
only has a single element. That's enough to use the API for now, which is why I don't want it to block the merging of this PR. I will address this in a separate PR that also adds tests forcomby
(which right now only does a single HTTP request which we likely need to change) -
CampaignPlan
s are not cleaned up yet. I already discussed this with @tsenart. - The
CampaignPlan.status
is still a dummy implementation.