Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
91870bae2ab6
Commit
576946f3
authored
Sep 27, 2018
by
Jacopo
Browse files
Includes commit stats in POST project commits API
parent
851fe22deea5
Changes
4
Hide whitespace changes
Inline
Side-by-side
changelogs/unreleased/51803-include-commits-stats-in-projects-api.yml
0 → 100644
View file @
91870bae
---
title
:
Includes commit stats in POST project commits API
merge_request
:
21968
author
:
Jacopo Beschi @jacopo-beschi
type
:
fixed
doc/api/commits.md
View file @
91870bae
...
...
@@ -79,6 +79,7 @@ POST /projects/:id/repository/commits
|
`actions[]`
| array | yes | An array of action hashes to commit as a batch. See the next table for what attributes it can take. |
|
`author_email`
| string | no | Specify the commit author's email address |
|
`author_name`
| string | no | Specify the commit author's name |
|
`stats`
| boolean | no | Include commit stats. Default is true |
|
`actions[]`
Attribute | Type | Required | Description |
...
...
lib/api/commits.rb
View file @
91870bae
...
...
@@ -98,6 +98,7 @@ def authorize_push_to_branch!(branch)
optional
:start_branch
,
type:
String
,
desc:
'Name of the branch to start the new commit from'
optional
:author_email
,
type:
String
,
desc:
'Author email for commit'
optional
:author_name
,
type:
String
,
desc:
'Author name for commit'
optional
:stats
,
type:
Boolean
,
default:
true
,
desc:
'Include commit stats'
end
post
':id/repository/commits'
do
authorize_push_to_branch!
(
params
[
:branch
])
...
...
@@ -113,7 +114,7 @@ def authorize_push_to_branch!(branch)
Gitlab
::
WebIdeCommitsCounter
.
increment
if
find_user_from_warden
present
commit_detail
,
with:
Entities
::
CommitDetail
present
commit_detail
,
with:
Entities
::
CommitDetail
,
stats:
params
[
:stats
]
else
render_api_error!
(
result
[
:message
],
400
)
end
...
...
spec/requests/api/commits_spec.rb
View file @
91870bae
...
...
@@ -572,6 +572,20 @@
expect
(
json_response
[
'title'
]).
to
eq
(
message
)
end
it
'includes the commit stats'
do
post
api
(
url
,
user
),
valid_mo_params
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
json_response
).
to
include
'stats'
end
it
"doesn't include the commit stats when stats is false"
do
post
api
(
url
,
user
),
valid_mo_params
.
merge
(
stats:
false
)
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
json_response
).
not_to
include
'stats'
end
it
'return a 400 bad request if there are any issues'
do
post
api
(
url
,
user
),
invalid_mo_params
...
...
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