Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit f52f466

Browse files
committed
campaigns: allow partial changeset publishing
1 parent c51a54a commit f52f466

File tree

9 files changed

+56
-129
lines changed

9 files changed

+56
-129
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All notable changes to Sourcegraph are documented in this file.
1616
- The new GraphQL API query field `namespaceByName(name: String!)` makes it easier to look up the user or organization with the given name. Previously callers needed to try looking up the user and organization separately.
1717
- Changesets created by campaigns will now include a link back to the campaign in their body text. [#14033](https://github.com/sourcegraph/sourcegraph/issues/14033)
1818
- Users can now preview commits that are going to be created in their repositories in the campaign preview UI. [#14181](https://github.com/sourcegraph/sourcegraph/pull/14181)
19+
- The `published` flag in campaign specs may now be an array, which allows only specific changesets within a campaign to be published based on the repository name. [#13476](https://github.com/sourcegraph/sourcegraph/pull/13476)
1920

2021
### Changed
2122

enterprise/internal/campaigns/resolvers/resolver_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/google/go-cmp/cmp"
1313
"github.com/graph-gophers/graphql-go"
14+
"github.com/sourcegraph/campaignutils/override"
1415
"github.com/sourcegraph/sourcegraph/cmd/frontend/backend"
1516
"github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend"
1617
"github.com/sourcegraph/sourcegraph/cmd/repo-updater/repos"
@@ -296,7 +297,7 @@ func TestApplyCampaign(t *testing.T) {
296297
Commit: campaigns.CommitTemplate{
297298
Message: "Add hello world",
298299
},
299-
Published: false,
300+
Published: override.FromBool(false),
300301
},
301302
},
302303
UserID: userID,

enterprise/internal/campaigns/store_campaign_specs_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"time"
77

88
"github.com/google/go-cmp/cmp"
9+
"github.com/sourcegraph/campaignutils/override"
910
"github.com/sourcegraph/sourcegraph/cmd/repo-updater/repos"
1011
"github.com/sourcegraph/sourcegraph/internal/campaigns"
1112
cmpgn "github.com/sourcegraph/sourcegraph/internal/campaigns"
@@ -28,7 +29,7 @@ func testStoreCampaignSpecs(t *testing.T, ctx context.Context, s *Store, _ repos
2829
Commit: campaigns.CommitTemplate{
2930
Message: "commit message",
3031
},
31-
Published: false,
32+
Published: override.FromBool(false),
3233
},
3334
},
3435
UserID: int32(i + 1234),

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ require (
149149
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546
150150
github.com/sirupsen/logrus v1.6.0 // indirect
151151
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d // indirect
152+
github.com/sourcegraph/campaignutils v0.0.0-20200930003955-ca2b439dad80
152153
github.com/sourcegraph/codeintelutils v0.0.0-20200824140252-1db3aed5cf58
153154
github.com/sourcegraph/ctxvfs v0.0.0-20180418081416-2b65f1b1ea81
154155
github.com/sourcegraph/go-ctags v0.0.0-20200922223002-071e508aa451

go.sum

Lines changed: 2 additions & 116 deletions
Large diffs are not rendered by default.

internal/campaigns/campaign_spec.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package campaigns
33
import (
44
"time"
55

6+
"github.com/sourcegraph/campaignutils/override"
67
"github.com/sourcegraph/sourcegraph/schema"
78
)
89

@@ -51,11 +52,12 @@ func (cs *CampaignSpec) ExpiresAt() time.Time {
5152
}
5253

5354
type CampaignSpecFields struct {
54-
Name string `json:"name"`
55-
Description string `json:"description"`
56-
On []CampaignSpecOn `json:"on"`
57-
Steps []CampaignSpecStep `json:"steps"`
58-
ChangesetTemplate ChangesetTemplate `json:"changesetTemplate"`
55+
Name string `json:"name"`
56+
Description string `json:"description"`
57+
On []CampaignSpecOn `json:"on"`
58+
Steps []CampaignSpecStep `json:"steps"`
59+
ImportChangeset []CampaignImportChangeset `json:"importChangesets,omitempty"`
60+
ChangesetTemplate ChangesetTemplate `json:"changesetTemplate"`
5961
}
6062

6163
type CampaignSpecOn struct {
@@ -69,12 +71,17 @@ type CampaignSpecStep struct {
6971
Env map[string]string `json:"env"`
7072
}
7173

74+
type CampaignImportChangeset struct {
75+
Repository string `json:"repository"`
76+
ExternalIDs []interface{} `json:"externalIDs"`
77+
}
78+
7279
type ChangesetTemplate struct {
7380
Title string `json:"title"`
7481
Body string `json:"body"`
7582
Branch string `json:"branch"`
7683
Commit CommitTemplate `json:"commit"`
77-
Published bool `json:"published"`
84+
Published override.Bool `json:"published"`
7885
}
7986

8087
type CommitTemplate struct {

schema/campaign_spec.schema.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,24 @@
153153
}
154154
},
155155
"published": {
156-
"type": "boolean",
157156
"description": "Whether to publish the changeset. An unpublished changeset can be previewed on Sourcegraph by any person who can view the campaign, but its commit, branch, and pull request aren't created on the code host. A published changeset results in a commit, branch, and pull request being created on the code host.",
158-
"$comment": "TODO(sqs): Come up with a way to specify that only a subset of changesets should be published. For example, making `published` an array with some include/exclude syntax items."
157+
"oneOf": [
158+
{
159+
"type": "boolean",
160+
"description": "A single flag to control the publishing state for the entire campaign."
161+
},
162+
{
163+
"type": "array",
164+
"description": "A list of repository patterns to match. In the event multiple patterns match, the last matching pattern in the list will be used.",
165+
"items": {
166+
"type": "object",
167+
"description": "An object with one field: the key is the glob pattern to match against repository names; the value will be used as the published flag for matching repositories.",
168+
"additionalProperties": { "type": "boolean" },
169+
"minProperties": 1,
170+
"maxProperties": 1
171+
}
172+
}
173+
]
159174
}
160175
}
161176
}

schema/campaign_spec_stringdata.go

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/schema.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)