Skip to content
代码片段 群组 项目
提交 a4bb9993 编辑于 作者: dixpac's avatar dixpac
浏览文件

Add commit stats to commit api response

上级 17be364d
No related branches found
No related tags found
无相关合并请求
...@@ -22,6 +22,7 @@ v 8.11.0 (unreleased) ...@@ -22,6 +22,7 @@ v 8.11.0 (unreleased)
- Add the `sprockets-es6` gem - Add the `sprockets-es6` gem
- Multiple trigger variables show in separate lines (Katarzyna Kobierska Ula Budziszewska) - Multiple trigger variables show in separate lines (Katarzyna Kobierska Ula Budziszewska)
- Profile requests when a header is passed - Profile requests when a header is passed
- Add commit stats in commit api. !5517 (dixpac)
- Make error pages responsive (Takuya Noguchi) - Make error pages responsive (Takuya Noguchi)
- Change requests_profiles resource constraint to catch virtually any file - Change requests_profiles resource constraint to catch virtually any file
......
...@@ -81,6 +81,11 @@ Example response: ...@@ -81,6 +81,11 @@ Example response:
"parent_ids": [ "parent_ids": [
"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba" "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
], ],
"stats": {
"additions": 15,
"deletions": 10,
"total": 25
},
"status": "running" "status": "running"
} }
``` ```
......
...@@ -149,8 +149,13 @@ class RepoCommit < Grape::Entity ...@@ -149,8 +149,13 @@ class RepoCommit < Grape::Entity
expose :safe_message, as: :message expose :safe_message, as: :message
end end
class RepoCommitStats < Grape::Entity
expose :additions, :deletions, :total
end
class RepoCommitDetail < RepoCommit class RepoCommitDetail < RepoCommit
expose :parent_ids, :committed_date, :authored_date expose :parent_ids, :committed_date, :authored_date
expose :stats, using: Entities::RepoCommitStats
expose :status expose :status
end end
......
...@@ -73,9 +73,13 @@ ...@@ -73,9 +73,13 @@
context "authorized user" do context "authorized user" do
it "should return a commit by sha" do it "should return a commit by sha" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response['id']).to eq(project.repository.commit.id) expect(json_response['id']).to eq(project.repository.commit.id)
expect(json_response['title']).to eq(project.repository.commit.title) 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 end
it "should return a 404 error if not found" do it "should return a 404 error if not found" do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册