Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
156cc98d
Commit
156cc98d
authored
Mar 06, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify lib/api/merge_requests.rb with EE
parent
49f72d06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
21 deletions
+40
-21
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+40
-21
No files found.
lib/api/merge_requests.rb
View file @
156cc98d
...
@@ -6,6 +6,32 @@ module API
...
@@ -6,6 +6,32 @@ module API
helpers
::
Gitlab
::
IssuableMetadata
helpers
::
Gitlab
::
IssuableMetadata
# EE::API::MergeRequests would override the following helpers
helpers
do
params
:optional_params_ee
do
end
params
:merge_params_ee
do
end
def
update_merge_request_ee
(
merge_request
)
end
end
def
self
.
update_params_at_least_one_of
%i[
assignee_id
description
labels
milestone_id
remove_source_branch
state_event
target_branch
title
discussion_locked
]
end
helpers
do
helpers
do
def
find_merge_requests
(
args
=
{})
def
find_merge_requests
(
args
=
{})
args
=
declared_params
.
merge
(
args
)
args
=
declared_params
.
merge
(
args
)
...
@@ -31,6 +57,12 @@ module API
...
@@ -31,6 +57,12 @@ module API
mr
.
all_pipelines
mr
.
all_pipelines
end
end
def
check_sha_param!
(
params
,
merge_request
)
if
params
[
:sha
]
&&
merge_request
.
diff_head_sha
!=
params
[
:sha
]
render_api_error!
(
"SHA does not match HEAD of source branch:
#{
merge_request
.
diff_head_sha
}
"
,
409
)
end
end
params
:merge_requests_params
do
params
:merge_requests_params
do
optional
:state
,
type:
String
,
values:
%w[opened closed merged all]
,
default:
'all'
,
optional
:state
,
type:
String
,
values:
%w[opened closed merged all]
,
default:
'all'
,
desc:
'Return opened, closed, merged, or all merge requests'
desc:
'Return opened, closed, merged, or all merge requests'
...
@@ -106,16 +138,14 @@ module API
...
@@ -106,16 +138,14 @@ module API
render_api_error!
(
errors
,
400
)
render_api_error!
(
errors
,
400
)
end
end
params
:optional_params
_ce
do
params
:optional_params
do
optional
:description
,
type:
String
,
desc:
'The description of the merge request'
optional
:description
,
type:
String
,
desc:
'The description of the merge request'
optional
:assignee_id
,
type:
Integer
,
desc:
'The ID of a user to assign the merge request'
optional
:assignee_id
,
type:
Integer
,
desc:
'The ID of a user to assign the merge request'
optional
:milestone_id
,
type:
Integer
,
desc:
'The ID of a milestone to assign the merge request'
optional
:milestone_id
,
type:
Integer
,
desc:
'The ID of a milestone to assign the merge request'
optional
:labels
,
type:
String
,
desc:
'Comma-separated list of label names'
optional
:labels
,
type:
String
,
desc:
'Comma-separated list of label names'
optional
:remove_source_branch
,
type:
Boolean
,
desc:
'Remove source branch when merging'
optional
:remove_source_branch
,
type:
Boolean
,
desc:
'Remove source branch when merging'
end
params
:optional_params
do
use
:optional_params_ee
use
:optional_params_ce
end
end
end
end
...
@@ -240,18 +270,6 @@ module API
...
@@ -240,18 +270,6 @@ module API
success
Entities
::
MergeRequest
success
Entities
::
MergeRequest
end
end
params
do
params
do
# CE
at_least_one_of_ce
=
[
:assignee_id
,
:description
,
:labels
,
:milestone_id
,
:remove_source_branch
,
:state_event
,
:target_branch
,
:title
,
:discussion_locked
]
optional
:title
,
type:
String
,
allow_blank:
false
,
desc:
'The title of the merge request'
optional
:title
,
type:
String
,
allow_blank:
false
,
desc:
'The title of the merge request'
optional
:target_branch
,
type:
String
,
allow_blank:
false
,
desc:
'The target branch'
optional
:target_branch
,
type:
String
,
allow_blank:
false
,
desc:
'The target branch'
optional
:state_event
,
type:
String
,
values:
%w[close reopen]
,
optional
:state_event
,
type:
String
,
values:
%w[close reopen]
,
...
@@ -259,7 +277,7 @@ module API
...
@@ -259,7 +277,7 @@ module API
optional
:discussion_locked
,
type:
Boolean
,
desc:
'Whether the MR discussion is locked'
optional
:discussion_locked
,
type:
Boolean
,
desc:
'Whether the MR discussion is locked'
use
:optional_params
use
:optional_params
at_least_one_of
(
*
at_least_one_of_ce
)
at_least_one_of
(
*
::
API
::
MergeRequests
.
update_params_at_least_one_of
)
end
end
put
':id/merge_requests/:merge_request_iid'
do
put
':id/merge_requests/:merge_request_iid'
do
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-ce/issues/42318'
)
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-ce/issues/42318'
)
...
@@ -282,13 +300,14 @@ module API
...
@@ -282,13 +300,14 @@ module API
success
Entities
::
MergeRequest
success
Entities
::
MergeRequest
end
end
params
do
params
do
# CE
optional
:merge_commit_message
,
type:
String
,
desc:
'Custom merge commit message'
optional
:merge_commit_message
,
type:
String
,
desc:
'Custom merge commit message'
optional
:should_remove_source_branch
,
type:
Boolean
,
optional
:should_remove_source_branch
,
type:
Boolean
,
desc:
'When true, the source branch will be deleted if possible'
desc:
'When true, the source branch will be deleted if possible'
optional
:merge_when_pipeline_succeeds
,
type:
Boolean
,
optional
:merge_when_pipeline_succeeds
,
type:
Boolean
,
desc:
'When true, this merge request will be merged when the pipeline succeeds'
desc:
'When true, this merge request will be merged when the pipeline succeeds'
optional
:sha
,
type:
String
,
desc:
'When present, must have the HEAD SHA of the source branch'
optional
:sha
,
type:
String
,
desc:
'When present, must have the HEAD SHA of the source branch'
use
:merge_params_ee
end
end
put
':id/merge_requests/:merge_request_iid/merge'
do
put
':id/merge_requests/:merge_request_iid/merge'
do
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-ce/issues/42317'
)
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-ce/issues/42317'
)
...
@@ -304,9 +323,9 @@ module API
...
@@ -304,9 +323,9 @@ module API
render_api_error!
(
'Branch cannot be merged'
,
406
)
unless
merge_request
.
mergeable?
(
skip_ci_check:
merge_when_pipeline_succeeds
)
render_api_error!
(
'Branch cannot be merged'
,
406
)
unless
merge_request
.
mergeable?
(
skip_ci_check:
merge_when_pipeline_succeeds
)
if
params
[
:sha
]
&&
merge_request
.
diff_head_sha
!=
params
[
:sha
]
check_sha_param!
(
params
,
merge_request
)
render_api_error!
(
"SHA does not match HEAD of source branch:
#{
merge_request
.
diff_head_sha
}
"
,
409
)
end
update_merge_request_ee
(
merge_request
)
merge_params
=
{
merge_params
=
{
commit_message:
params
[
:merge_commit_message
],
commit_message:
params
[
:merge_commit_message
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment