Commit Graph

10 Commits

Author SHA1 Message Date
GitLab Bot 6a4ffad420 Add latest changes from gitlab-org/gitlab@master 2019-11-26 12:06:18 +00:00
Christian Couder f00db0c342 Support adding and removing labels w/ push opts
MergeRequests::PushOptionsHandlerService has been updated to allow
adding and removing labels to a merge request using git push options.

To create a new merge request and add 2 labels to it:

      git push -u origin -o merge_request.create \
        -o merge_request.label="My label 1" \
        -o merge_request.label="My label 2"

To update an existing merge request and remove a label while
adding a different label:

      git push -u origin -o merge_request.label="My added label" \
        -o merge_request.unlabel="My removed label"

Issue https://gitlab.com/gitlab-org/gitlab-ce/issues/64320
2019-09-04 12:11:24 +02:00
Christian Couder 7cf4bf848f Support title and desc on merge w/ push option
MergeRequests::PushOptionsHandlerService has been updated to allow
creating and updating merge requests with the `title` and
`description` set using git push options.

To create a new merge request and set its title and description:

      git push -u origin -o merge_request.create \
        -o merge_request.title="My title" \
        -o merge_request.description="My description"

To update an existing merge request and set its title and
description:

      git push -u origin -o merge_request.title="My title" \
        -o merge_request.description="My description"

Issue https://gitlab.com/gitlab-org/gitlab-ce/issues/64320
2019-07-24 11:04:49 +02:00
Christian Couder 0d98f1bba2 Refactor create_params and update_params
Let's move shared code between create_params and update_params
into a new base_params.

update_params becomes very thin, but it still may be clearer that
the params are being shared if we have a method called
base_params, rather than have create_params merge in
update_params.
2019-07-17 13:33:09 +02:00
Christian Couder 8256d4075d Support rm src branch on merge w/ push option
MergeRequests::PushOptionsHandlerService has been updated to allow
creating and updating merge requests with the
`remove_source_branch` set using git push options.

To create a new merge request and set it to remove the source branch
when it is merged:

  git push -u origin -o merge_request.create \
    -o merge_request.remove_source_branch

To update an existing merge request and set it to remove the source
branch when it is merged:

  git push -u origin -o merge_request.remove_source_branch

Issue https://gitlab.com/gitlab-org/gitlab-ce/issues/64320
2019-07-17 13:32:41 +02:00
Nick Thomas f9b4d5efbd
Fix MR assignees for push options
With multiple MR assignees, `merge_request.assignee_id` is always nil,
and `merge_request.assignee_ids` isn't in `merge_request.attributes`.
So the existing code doesn't set assignees in the created MR.

This fix gets all the tests passing, but we should also check that no
other associations in the MergeRequest need similar fixups.
2019-04-09 20:40:12 +01:00
Luke Duncalfe b5bcf80c9a Update service to handle unexpected exceptions
This will ensure that now and in the future, PushOptionsHandlerService
will not cause the post_receive API endpoint from running other code if
something causes an unknown exception.
2019-04-09 10:57:04 +12:00
Luke Duncalfe e73f537cb5 Refactor PushOptionsHandlerService from review
Exceptions are no longer raised, instead all errors encountered are
added to the errors property.

MergeRequests::BuildService is used to generate attributes of a new
merge request.

Code moved from Api::Internal to Api::Helpers::InternalHelpers.
2019-04-09 10:57:01 +12:00
Luke Duncalfe 68f189ad23 Support merge on pipeline success w/ push options
MergeRequests::PushOptionsHandlerService has been updated to allow
creating and updating merge requests with the
`merge_when_pipeline_succeeds` set using git push options.

To create a new merge request and set it to merge when the pipeline
succeeds:

  git push -u origin -o merge_request.create \
    -o merge_request.merge_when_pipeline_succeeds

To update an existing merge request and set it to merge when the
pipeline succeeds:

  git push -u origin -o merge_request.merge_when_pipeline_succeeds

Issue https://gitlab.com/gitlab-org/gitlab-ce/issues/53198
2019-04-09 10:03:26 +12:00
Luke Duncalfe aa352a95df Support merge request create with push options
To create a new merge request:

  git push -u origin -o merge_request.create

To create a new merge request setting target branch:

  git push -u origin -o merge_request.create \
    -o merge_request.target=123

To update an existing merge request with a new target branch:

  git push -u origin -o merge_request.target=123

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 issue
https://gitlab.com/gitlab-org/gitlab-ce/issues/43263.

E.g. these push options:

  -o merge_request.create -o merge_request.target=123

Become parsed 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.

Issue https://gitlab.com/gitlab-org/gitlab-ce/issues/43263
2019-04-09 09:36:42 +12:00