Merge branch 'add_commit_stats' into 'master'
Add commit stats ## What does this MR do? When getting commit by SHA in api it returns commit stats ## Are there points in the code the reviewer needs to double check? Not sure about test I added do we need separate test or we can just shove stats assertion in test above ## Why was this MR needed? So api users/clients can get statistics on single commit ## What are the relevant issue numbers? #20307 ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [x] API support added - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5517
This commit is contained in:
commit
a88a4e857c
|
@ -22,6 +22,7 @@ v 8.11.0 (unreleased)
|
|||
- Add the `sprockets-es6` gem
|
||||
- Multiple trigger variables show in separate lines (Katarzyna Kobierska Ula Budziszewska)
|
||||
- Profile requests when a header is passed
|
||||
- Add commit stats in commit api. !5517 (dixpac)
|
||||
- Make error pages responsive (Takuya Noguchi)
|
||||
- Change requests_profiles resource constraint to catch virtually any file
|
||||
|
||||
|
|
|
@ -81,6 +81,11 @@ Example response:
|
|||
"parent_ids": [
|
||||
"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
|
||||
],
|
||||
"stats": {
|
||||
"additions": 15,
|
||||
"deletions": 10,
|
||||
"total": 25
|
||||
},
|
||||
"status": "running"
|
||||
}
|
||||
```
|
||||
|
|
|
@ -149,8 +149,13 @@ module API
|
|||
expose :safe_message, as: :message
|
||||
end
|
||||
|
||||
class RepoCommitStats < Grape::Entity
|
||||
expose :additions, :deletions, :total
|
||||
end
|
||||
|
||||
class RepoCommitDetail < RepoCommit
|
||||
expose :parent_ids, :committed_date, :authored_date
|
||||
expose :stats, using: Entities::RepoCommitStats
|
||||
expose :status
|
||||
end
|
||||
|
||||
|
|
|
@ -73,9 +73,13 @@ describe API::API, api: true do
|
|||
context "authorized user" do
|
||||
it "should return a commit by sha" do
|
||||
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(json_response['id']).to eq(project.repository.commit.id)
|
||||
expect(json_response['title']).to eq(project.repository.commit.title)
|
||||
expect(json_response['stats']['additions']).to eq(project.repository.commit.stats.additions)
|
||||
expect(json_response['stats']['deletions']).to eq(project.repository.commit.stats.deletions)
|
||||
expect(json_response['stats']['total']).to eq(project.repository.commit.stats.total)
|
||||
end
|
||||
|
||||
it "should return a 404 error if not found" do
|
||||
|
|
Loading…
Reference in New Issue