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
f3834e9c
Commit
f3834e9c
authored
Sep 27, 2018
by
Jacopo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Includes commit stats in POST project commits API
parent
f4db21eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
1 deletion
+22
-1
changelogs/unreleased/51803-include-commits-stats-in-projects-api.yml
...nreleased/51803-include-commits-stats-in-projects-api.yml
+5
-0
doc/api/commits.md
doc/api/commits.md
+1
-0
lib/api/commits.rb
lib/api/commits.rb
+2
-1
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+14
-0
No files found.
changelogs/unreleased/51803-include-commits-stats-in-projects-api.yml
0 → 100644
View file @
f3834e9c
---
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 @
f3834e9c
...
...
@@ -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 @
f3834e9c
...
...
@@ -98,6 +98,7 @@ module API
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 @@ module API
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 @
f3834e9c
...
...
@@ -572,6 +572,20 @@ describe API::Commits do
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