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
0e076f80
Commit
0e076f80
authored
Jul 30, 2020
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include dry_run error field for failed dry run operation
parent
e20fe9f1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
lib/api/commits.rb
lib/api/commits.rb
+10
-4
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+20
-0
No files found.
lib/api/commits.rb
View file @
0e076f80
...
...
@@ -203,7 +203,7 @@ module API
params
do
requires
:sha
,
type:
String
,
desc:
'A commit sha, or the name of a branch or tag to be cherry picked'
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
,
allow_blank:
false
optional
:dry_run
,
type:
Boolean
,
default:
false
,
desc:
"Do
n'
t commit any changes"
optional
:dry_run
,
type:
Boolean
,
default:
false
,
desc:
"Do
es no
t commit any changes"
end
post
':id/repository/commits/:sha/cherry_pick'
,
requirements:
API
::
COMMIT_ENDPOINT_REQUIREMENTS
do
authorize_push_to_branch!
(
params
[
:branch
])
...
...
@@ -233,7 +233,10 @@ module API
with:
Entities
::
Commit
end
else
error!
(
result
.
slice
(
:message
,
:error_code
),
400
,
header
)
response
=
result
.
slice
(
:message
,
:error_code
)
response
[
:dry_run
]
=
:error
if
params
[
:dry_run
]
error!
(
response
,
400
,
header
)
end
end
...
...
@@ -244,7 +247,7 @@ module API
params
do
requires
:sha
,
type:
String
,
desc:
'Commit SHA to revert'
requires
:branch
,
type:
String
,
desc:
'Target branch name'
,
allow_blank:
false
optional
:dry_run
,
type:
Boolean
,
default:
false
,
desc:
"Do
n'
t commit any changes"
optional
:dry_run
,
type:
Boolean
,
default:
false
,
desc:
"Do
es no
t commit any changes"
end
post
':id/repository/commits/:sha/revert'
,
requirements:
API
::
COMMIT_ENDPOINT_REQUIREMENTS
do
authorize_push_to_branch!
(
params
[
:branch
])
...
...
@@ -274,7 +277,10 @@ module API
with:
Entities
::
Commit
end
else
error!
(
result
.
slice
(
:message
,
:error_code
),
400
,
header
)
response
=
result
.
slice
(
:message
,
:error_code
)
response
[
:dry_run
]
=
:error
if
params
[
:dry_run
]
error!
(
response
,
400
,
header
)
end
end
...
...
spec/requests/api/commits_spec.rb
View file @
0e076f80
...
...
@@ -1543,6 +1543,14 @@ RSpec.describe API::Commits do
expect
(
json_response
[
'error_code'
]).
to
eq
'empty'
end
it
'includes an additional dry_run error field when enabled'
do
post
api
(
route
,
current_user
),
params:
{
branch:
'markdown'
,
dry_run:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error_code'
]).
to
eq
'empty'
expect
(
json_response
[
'dry_run'
]).
to
eq
'error'
end
end
context
'when ref contains a dot'
do
...
...
@@ -1724,6 +1732,18 @@ RSpec.describe API::Commits do
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error_code'
]).
to
eq
'empty'
end
it
'includes an additional dry_run error field when enabled'
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'
,
dry_run:
true
}
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error_code'
]).
to
eq
'empty'
expect
(
json_response
[
'dry_run'
]).
to
eq
'error'
end
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