Extend GraphQL API to commit to a new branch in a single operation
What does this MR do?
Extend resolver to commit to a new branch
Users may want to create a new branch along with their commit, as when creating a new merge request.
This merge request adds a new optional parameter "startBranch" to the commitCreate
mutation, so users can also add a new branch when creating a commit
Example mutation
This mutation creates a new branch with the new commit:
mutation commitCIFileMutation(
$projectPath: ID!
$branch: String!
$startBranch: String!
$message: String!
$filePath: String!
$lastCommitId: String!
$content: String
) {
commitCreate(
input: {
projectPath: $projectPath
branch: $branch,
startBranch: $startBranch,
message: $message
actions: [
{ action: UPDATE, filePath: $filePath, lastCommitId: $lastCommitId, content: $content }
]
}
) {
commit {
id
}
errors
}
}
{
"branch": "new-branch",
"startBranch": "master",
"content": "stages:\n - test\n\nvariables:\n TEST: \n value: \"HELLO 2\"\n description: \"This variable makes cakes delicious\"\n TEST_2:\n value: \"HELLO TOO\"\n description: \"\"\n TEST_3: \"HELLO 3\"\n\ntest_variable:\n stage: test\n script:\n - echo \"$TEST\"",
"filePath": ".gitlab-ci.yml",
"lastCommitId": "e270ea9cb5c597281f32160e3c769b1b7f9a019b",
"message": "Update .gitlab-ci.yml file",
"projectPath": "root/my-ci-variables"
}
Screenshots (strongly suggested)
GraphiQL
Example use case
When commiting changes to a file, we may want to choose a new branch to commit to, and even open a new merge request.
See more at the next MR: !47083 (merged).
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related to #263144 (closed)
Edited by Miguel Rincon