Skip to content

Commit c7922ae

Browse files
authored
Add draft option support for publish in changeset template (#350)
Using the introduced triple of true/false/"draft", users can now specify to open a PR in draft mode on the code host.
1 parent fbb98e0 commit c7922ae

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/olekukonko/tablewriter v0.0.4 // indirect
1919
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
2020
github.com/pkg/errors v0.9.1
21-
github.com/sourcegraph/campaignutils v0.0.0-20200930165749-a8777d33a817
21+
github.com/sourcegraph/campaignutils v0.0.0-20201014140011-721315691938
2222
github.com/sourcegraph/codeintelutils v0.0.0-20200824140252-1db3aed5cf58
2323
github.com/sourcegraph/go-diff v0.6.0
2424
github.com/sourcegraph/jsonx v0.0.0-20200629203448-1a936bd500cf

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
4848
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4949
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
5050
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
51-
github.com/sourcegraph/campaignutils v0.0.0-20200930165749-a8777d33a817 h1:mdFA7I2rnfl8AV0m8iMb4uoQb3GRdjRsgRMREoNGEk4=
52-
github.com/sourcegraph/campaignutils v0.0.0-20200930165749-a8777d33a817/go.mod h1:5P8k8KlKz78RZJ2EFk9k9ln/j/twj28z/+BvO5hHZJ8=
51+
github.com/sourcegraph/campaignutils v0.0.0-20201014140011-721315691938 h1:h5gOw7sMlYFSQFNdFPXNHJ4dtD0nlgClmL8SGAzlNM4=
52+
github.com/sourcegraph/campaignutils v0.0.0-20201014140011-721315691938/go.mod h1:5P8k8KlKz78RZJ2EFk9k9ln/j/twj28z/+BvO5hHZJ8=
5353
github.com/sourcegraph/codeintelutils v0.0.0-20200824140252-1db3aed5cf58 h1:Ps+U1xoZP+Zoph39YfRB6Q846ghO8pgrAgp0MiObvPs=
5454
github.com/sourcegraph/codeintelutils v0.0.0-20200824140252-1db3aed5cf58/go.mod h1:HplI8gRslTrTUUsSYwu28hSOderix7m5dHNca7xBzeo=
5555
github.com/sourcegraph/go-diff v0.6.0 h1:WbN9e/jD8ujU+o0vd9IFN5AEwtfB0rn/zM/AANaClqQ=

internal/campaigns/campaign_spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type ChangesetTemplate struct {
4141
Body string `json:"body,omitempty" yaml:"body"`
4242
Branch string `json:"branch,omitempty" yaml:"branch"`
4343
Commit ExpandedGitCommitDescription `json:"commit,omitempty" yaml:"commit"`
44-
Published overridable.Bool `json:"published" yaml:"published"`
44+
Published overridable.BoolOrString `json:"published" yaml:"published"`
4545
}
4646

4747
type GitCommitAuthor struct {

internal/campaigns/changeset_spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type CreatedChangeset struct {
2222
Title string `json:"title"`
2323
Body string `json:"body"`
2424
Commits []GitCommitDescription `json:"commits"`
25-
Published bool `json:"published"`
25+
Published interface{} `json:"published"`
2626
}
2727

2828
type GitCommitDescription struct {

schema/campaign_spec.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
"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.",
157157
"oneOf": [
158158
{
159-
"type": "boolean",
159+
"oneOf": [{ "type": "boolean" }, { "type": "string", "pattern": "^draft$" }],
160160
"description": "A single flag to control the publishing state for the entire campaign."
161161
},
162162
{
@@ -165,7 +165,7 @@
165165
"items": {
166166
"type": "object",
167167
"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" },
168+
"additionalProperties": { "oneOf": [{ "type": "boolean" }, { "type": "string", "pattern": "^draft$" }] },
169169
"minProperties": 1,
170170
"maxProperties": 1
171171
}

schema/campaign_spec_stringdata.go

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

0 commit comments

Comments
 (0)