Git push options to create a merge request, set target_branch and set merge when pipeline succeeds
What does this MR do?
Adds the ability to perform the following with git push options:
- create a merge request
- set the target branch of a merge request
- set merge request to merge when its pipeline succeeds
Merge request creation
To create a new merge request:
git push -u origin -o merge_request.create
To create a new merge request, set its target branch, and set it to merge when its pipeline succeeds:
git push -u origin -o merge_request.create \
-o merge_request.target=branch1 \
-o merge_request.merge_when_pipeline_succeeds
Updating existing merge requests
When pushing branches with an existing open merge request, target
and merge_when_pipeline_succeeds
can be used to update the merge request.
Internals
A new Gitlab::PushOptions
class handles parsing and validating the push
options array. This can be the start of the standard of GitLab accepting
push options that follow namespacing rules. Rules are discussed in
https://gitlab.com/gitlab-org/gitlab-ce/issues/43263#note_147777088
E.g. these push options:
-o merge_request.create -o merge_request.target=123
Become parsed by the Gitlab::PushOptions
class as:
{
merge_request: {
create: true,
target: '123',
}
}
And are fetched with the class via:
push_options.get(:merge_request)
push_options.get(:merge_request, :create)
push_options.get(:merge_request, :target)
A new MergeRequests::PushOptionsHandlerService
takes the merge_request
namespaced push options and handles creating and updating
merge requests.
Any errors encountered are passed to the existing output
Hash in
Api::Internal
's post_receive
endpoint, and passed to gitlab-shell
where they're output to the user.
What are the relevant issue numbers?
- https://gitlab.com/gitlab-org/gitlab-ce/issues/43263
- https://gitlab.com/gitlab-org/gitlab-ce/issues/53198
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides
Closes #43263 (closed)
Merge request reports
Activity
changed milestone to %11.10
added Create [DEPRECATED] Deliverable backend devopscreate merge requests ~2975006 workflowin dev labels
2 Warnings The title of this merge request is longer than 72 characters and would violate our commit message rules when using the Squash on Merge feature. Please consider adjusting the title, or rebase the commits manually and don’t use Squash on Merge. This merge request is quite big (more than 979 lines changed), please consider splitting it into multiple merge requests. 1 Message This merge request adds or changes files that require a review from the Technical Writing team. Documentation review
The following files require a review from a technical writer:
doc/user/project/merge_requests/index.md
The review does not need to block merging this merge request. See the:
- DevOps stages for the appropriate technical writer for this review.
- Documentation workflows for information on when to assign a merge request for review.
Reviewer roulette
Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.
To spread load more evenly across eligible reviewers, Danger has randomly picked a candidate for each review slot. Feel free to override this selection if you think someone else would be better-suited, or the chosen person is unavailable.
Once you've decided who will review this merge request, mention them as you normally would! Danger does not (yet?) automatically notify them for you.
Category Reviewer Maintainer backend Imre Farkas ( @ifarkas
)Kamil Trzciński ( @ayufan
)~Documentation Achilleas Pipinellis ( @axil
)Generated by
DangerEdited by 🤖 GitLab Bot 🤖added 1 commit
- 644f93c3 - Support merge request create with push options
marked the checklist item Changelog entry added, if necessary as completed
added 2 commits
marked the checklist item Tests added for this feature/bug as completed
marked the checklist item Conforms to the code review guidelines as completed
marked the checklist item Conforms to the merge request performance guidelines as completed
marked the checklist item Conforms to the style guides as completed
marked the checklist item Conforms to the database guides as completed
git push options has been enabled on the review app, so this feature can be tested out.
Just recording the steps to enable push options (based on these instructions):
- Visit workloads page. Type
name:
(wait for filtering options to appear), type43263
(wait for filtering of options to happen), choose the one that ends in-gitaly
. - Click the link in the
name
column - Scroll down, click the name under the "Managed pods" section
- Go
KUBECTL
>exec
>gitaly
- Virtual terminal will load
- An example command will appear that will
ls
the server. Replacels
withgit config --global receive.advertisePushOptions true
and hit return. Can confim by exec'inggit config --get receive.advertisePushOptions
Edited by Luke Duncalfe- Visit workloads page. Type
added 386 commits
-
5075f202...afbc8274 - 385 commits from branch
master
- 7ffb48ab - Support merge request create with push options
-
5075f202...afbc8274 - 385 commits from branch
added 1 commit
- ca410dc1 - Support merge request create with push options
added 1 commit
- b7c58f4d - Support merge request create with push options
Hi @eread
Lucky you have been chosen by a roll of a virtual die to be the documentation reviewer for this MR! Could you please take a look and provide some of your please? Thank you!marked the checklist item Documentation created/updated via this MR as completed