Commit f3834e9c authored by Jacopo's avatar Jacopo

Includes commit stats in POST project commits API

parent f4db21eb
---
title: Includes commit stats in POST project commits API
merge_request: 21968
author: Jacopo Beschi @jacopo-beschi
type: fixed
...@@ -79,6 +79,7 @@ POST /projects/:id/repository/commits ...@@ -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. | | `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_email` | string | no | Specify the commit author's email address |
| `author_name` | string | no | Specify the commit author's name | | `author_name` | string | no | Specify the commit author's name |
| `stats` | boolean | no | Include commit stats. Default is true |
| `actions[]` Attribute | Type | Required | Description | | `actions[]` Attribute | Type | Required | Description |
......
...@@ -98,6 +98,7 @@ module API ...@@ -98,6 +98,7 @@ module API
optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from' 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_email, type: String, desc: 'Author email for commit'
optional :author_name, type: String, desc: 'Author name for commit' optional :author_name, type: String, desc: 'Author name for commit'
optional :stats, type: Boolean, default: true, desc: 'Include commit stats'
end end
post ':id/repository/commits' do post ':id/repository/commits' do
authorize_push_to_branch!(params[:branch]) authorize_push_to_branch!(params[:branch])
...@@ -113,7 +114,7 @@ module API ...@@ -113,7 +114,7 @@ module API
Gitlab::WebIdeCommitsCounter.increment if find_user_from_warden Gitlab::WebIdeCommitsCounter.increment if find_user_from_warden
present commit_detail, with: Entities::CommitDetail present commit_detail, with: Entities::CommitDetail, stats: params[:stats]
else else
render_api_error!(result[:message], 400) render_api_error!(result[:message], 400)
end end
......
...@@ -572,6 +572,20 @@ describe API::Commits do ...@@ -572,6 +572,20 @@ describe API::Commits do
expect(json_response['title']).to eq(message) expect(json_response['title']).to eq(message)
end 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 it 'return a 400 bad request if there are any issues' do
post api(url, user), invalid_mo_params post api(url, user), invalid_mo_params
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment