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
Jérome Perrin
gitlab-ce
Commits
3f4e215c
Commit
3f4e215c
authored
Feb 05, 2013
by
Sebastian Ziebell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extracted helper method to avoid code duplication
parent
413952ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+19
-14
No files found.
lib/api/merge_requests.rb
View file @
3f4e215c
...
...
@@ -5,6 +5,23 @@ module Gitlab
resource
:projects
do
helpers
do
# If an error occurred this helper method provides an appropriate status code
#
# Parameters:
# merge_request_errors (required) - The errors collection of MR
#
def
handle_merge_request_error
(
merge_request_errors
)
if
merge_request_errors
[
:target_branch
].
any?
error!
(
merge_request_errors
[
:target_branch
],
400
)
elsif
merge_request_errors
[
:source_branch
].
any?
error!
(
merge_request_errors
[
:source_branch
],
400
)
elsif
merge_request_errors
[
:base
].
any?
error!
(
merge_request_errors
[
:base
],
422
)
end
end
end
# List merge requests
#
# Parameters:
...
...
@@ -60,13 +77,7 @@ module Gitlab
merge_request
.
reload_code
present
merge_request
,
with:
Entities
::
MergeRequest
else
if
merge_request
.
errors
[
:target_branch
].
any?
error!
(
merge_request
.
errors
[
:target_branch
],
400
)
elsif
merge_request
.
errors
[
:source_branch
].
any?
error!
(
merge_request
.
errors
[
:source_branch
],
400
)
elsif
merge_request
.
errors
[
:base
].
any?
error!
(
merge_request
.
errors
[
:base
],
422
)
end
handle_merge_request_error
(
merge_request
.
errors
)
not_found!
end
end
...
...
@@ -95,13 +106,7 @@ module Gitlab
merge_request
.
mark_as_unchecked
present
merge_request
,
with:
Entities
::
MergeRequest
else
if
merge_request
.
errors
[
:target_branch
].
any?
error!
(
merge_request
.
errors
[
:target_branch
],
400
)
elsif
merge_request
.
errors
[
:source_branch
].
any?
error!
(
merge_request
.
errors
[
:source_branch
],
400
)
elsif
merge_request
.
errors
[
:base
].
any?
error!
(
merge_request
.
errors
[
:base
],
422
)
end
handle_merge_request_error
(
merge_request
.
errors
)
not_found!
end
end
...
...
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