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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
bc57ad04
Commit
bc57ad04
authored
Nov 05, 2019
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `error_code` to cherry-pick/revert responses
parent
85fd72fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
lib/api/commits.rb
lib/api/commits.rb
+2
-2
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+19
-0
No files found.
lib/api/commits.rb
View file @
bc57ad04
...
...
@@ -223,7 +223,7 @@ module API
present
user_project
.
repository
.
commit
(
result
[
:result
]),
with:
Entities
::
Commit
else
render_api_error!
(
result
[
:message
],
400
)
error!
(
result
.
slice
(
:message
,
:error_code
),
400
,
header
)
end
end
...
...
@@ -257,7 +257,7 @@ module API
present
user_project
.
repository
.
commit
(
result
[
:result
]),
with:
Entities
::
Commit
else
render_api_error!
(
result
[
:message
],
400
)
error!
(
result
.
slice
(
:message
,
:error_code
),
400
,
header
)
end
end
...
...
spec/requests/api/commits_spec.rb
View file @
bc57ad04
...
...
@@ -1376,6 +1376,12 @@ describe API::Commits do
it_behaves_like
'400 response'
do
let
(
:request
)
{
post
api
(
route
,
current_user
),
params:
{
branch:
'markdown'
}
}
end
it
'includes an error_code in the response'
do
post
api
(
route
,
current_user
),
params:
{
branch:
'markdown'
}
expect
(
json_response
[
'error_code'
]).
to
eq
'empty'
end
end
context
'when ref contains a dot'
do
...
...
@@ -1535,6 +1541,19 @@ describe API::Commits do
let
(
:request
)
{
post
api
(
route
,
current_user
)
}
end
end
context
'when commit is already reverted in the target branch'
do
it
'includes an error_code in the response'
do
# First one actually reverts
post
api
(
route
,
current_user
),
params:
{
branch:
'markdown'
}
# Second one is redundant and should be empty
post
api
(
route
,
current_user
),
params:
{
branch:
'markdown'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'error_code'
]).
to
eq
'empty'
end
end
end
context
'when authenticated'
,
'as a developer'
do
...
...
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