Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLab FOSSGitLab FOSS
  • Merge requests
  • !26752

Git push options to create a merge request, set target_branch and set merge when pipeline succeeds

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Luke Duncalfe requested to merge 43263-git-push-option-to-create-mr into master Mar 29, 2019
  • Overview 107
  • Commits 7
  • Pipelines 32
  • Changes 17

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)

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53198

Edited Apr 07, 2019 by Luke Duncalfe
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: 43263-git-push-option-to-create-mr