[Backport 5.2] code-search: handle changeset fork when creating a batch change via src-cli (#58344)

Co-authored-by: Bolaji Olajide <25608335+BolajiOlajide@users.noreply.github.com>
This commit is contained in:
sourcegraph-release-guild-bot 2023-11-15 13:25:27 -05:00 committed by GitHub
parent 8e2f9d0deb
commit ae6d930bb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 0 deletions

View File

@ -103,6 +103,7 @@ func (c *ChangesetSpec) MarshalJSON() ([]byte, error) {
Body string `json:"body,omitempty"`
Commits []GitCommitDescription `json:"commits,omitempty"`
Published *PublishedValue `json:"published,omitempty"`
Fork *bool `json:"fork,omitempty"`
}{
BaseRepository: c.BaseRepository,
ExternalID: c.ExternalID,
@ -113,6 +114,7 @@ func (c *ChangesetSpec) MarshalJSON() ([]byte, error) {
Title: c.Title,
Body: c.Body,
Commits: c.Commits,
Fork: c.Fork,
}
if !c.Published.Nil() {
v.Published = &c.Published

View File

@ -111,6 +111,26 @@ func TestParseChangesetSpec(t *testing.T) {
}`,
err: "2 errors occurred:\n\t* Must validate one and only one schema (oneOf)\n\t* commits: Array must have at most 1 items",
},
{
name: "with fork",
rawSpec: `{
"baseRepository": "graphql-id",
"baseRef": "refs/heads/master",
"baseRev": "d34db33f",
"headRef": "refs/heads/my-branch",
"headRepository": "graphql-id",
"title": "my title",
"body": "my body",
"published": false,
"commits": [{
"message": "commit message",
"diff": "the diff",
"authorName": "Mary McButtons",
"authorEmail": "mary@example.com"
}],
"fork": true
}`,
},
}
for _, tc := range tests {

View File

@ -60,6 +60,10 @@ const ChangesetSpecJSON = `{
"description": "The GraphQL ID of the repository that contains the branch with this changeset's changes. Fork repositories and cross-repository changesets are not yet supported. Therefore, headRepository must be equal to baseRepository.",
"examples": ["UmVwb3NpdG9yeTo5Cg=="]
},
"fork": {
"type": "boolean",
"description": "Whether to publish the changeset to a fork of the target repository. If omitted, the changeset will be published to a branch directly on the target repository, unless the global ` + "`" + `batches.enforceFork` + "`" + ` setting is enabled. If set, this property will override any global setting."
},
"headRef": {
"type": "string",
"description": "The full name of the Git ref that holds the changes proposed by this changeset. This ref will be created or updated with the commits.",

View File

@ -55,6 +55,10 @@
"description": "The GraphQL ID of the repository that contains the branch with this changeset's changes. Fork repositories and cross-repository changesets are not yet supported. Therefore, headRepository must be equal to baseRepository.",
"examples": ["UmVwb3NpdG9yeTo5Cg=="]
},
"fork": {
"type": "boolean",
"description": "Whether to publish the changeset to a fork of the target repository. If omitted, the changeset will be published to a branch directly on the target repository, unless the global `batches.enforceFork` setting is enabled. If set, this property will override any global setting."
},
"headRef": {
"type": "string",
"description": "The full name of the Git ref that holds the changes proposed by this changeset. This ref will be created or updated with the commits.",

View File

@ -478,6 +478,8 @@ type BranchChangesetSpec struct {
Body string `json:"body"`
// Commits description: The Git commits with the proposed changes. These commits are pushed to the head ref.
Commits []*GitCommitDescription `json:"commits"`
// Fork description: Whether to publish the changeset to a fork of the target repository. If omitted, the changeset will be published to a branch directly on the target repository, unless the global `batches.enforceFork` setting is enabled. If set, this property will override any global setting.
Fork bool `json:"fork,omitempty"`
// HeadRef description: The full name of the Git ref that holds the changes proposed by this changeset. This ref will be created or updated with the commits.
HeadRef string `json:"headRef"`
// HeadRepository description: The GraphQL ID of the repository that contains the branch with this changeset's changes. Fork repositories and cross-repository changesets are not yet supported. Therefore, headRepository must be equal to baseRepository.