Skip to content

Commit bd67459

Browse files
committed
Merge branch 'api-expose-commiter-details' into 'master'
API: Expose committer details for a commit Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/22312 See merge request !7849
2 parents 0819d09 + 79d99d4 commit bd67459

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: 'API: Expose committer details for commits'
3+
merge_request:
4+
author: Robert Schilling

doc/api/commits.md

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Example response:
2929
"title": "Replace sanitize with escape once",
3030
"author_name": "Dmitriy Zaporozhets",
3131
"author_email": "[email protected]",
32+
"committer_name": "Administrator",
33+
"committer_email": "[email protected]",
3234
"created_at": "2012-09-20T11:50:22+03:00",
3335
"message": "Replace sanitize with escape once",
3436
"allow_failure": false
@@ -39,6 +41,8 @@ Example response:
3941
"title": "Sanitize for network graph",
4042
"author_name": "randx",
4143
"author_email": "[email protected]",
44+
"committer_name": "Dmitriy",
45+
"committer_email": "[email protected]",
4246
"created_at": "2012-09-20T09:06:12+03:00",
4347
"message": "Sanitize for network graph",
4448
"allow_failure": false
@@ -115,6 +119,8 @@ Example response:
115119
"title": "some commit message",
116120
"author_name": "Dmitriy Zaporozhets",
117121
"author_email": "[email protected]",
122+
"committer_name": "Dmitriy Zaporozhets",
123+
"committer_email": "[email protected]",
118124
"created_at": "2016-09-20T09:26:24.000-07:00",
119125
"message": "some commit message",
120126
"parent_ids": [
@@ -159,6 +165,8 @@ Example response:
159165
"title": "Sanitize for network graph",
160166
"author_name": "randx",
161167
"author_email": "[email protected]",
168+
"committer_name": "Dmitriy",
169+
"committer_email": "[email protected]",
162170
"created_at": "2012-09-20T09:06:12+03:00",
163171
"message": "Sanitize for network graph",
164172
"committed_date": "2012-09-20T09:06:12+03:00",

lib/api/entities.rb

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class RepoTreeObject < Grape::Entity
174174

175175
class RepoCommit < Grape::Entity
176176
expose :id, :short_id, :title, :author_name, :author_email, :created_at
177+
expose :committer_name, :committer_email
177178
expose :safe_message, as: :message
178179
end
179180

spec/requests/api/commits_spec.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
before { project.team << [user2, :reporter] }
1919

2020
it "returns project commits" do
21+
commit = project.repository.commit
2122
get api("/projects/#{project.id}/repository/commits", user)
22-
expect(response).to have_http_status(200)
2323

24+
expect(response).to have_http_status(200)
2425
expect(json_response).to be_an Array
25-
expect(json_response.first['id']).to eq(project.repository.commit.id)
26+
expect(json_response.first['id']).to eq(commit.id)
27+
expect(json_response.first['committer_name']).to eq(commit.committer_name)
28+
expect(json_response.first['committer_email']).to eq(commit.committer_email)
2629
end
2730
end
2831

@@ -134,6 +137,8 @@
134137

135138
expect(response).to have_http_status(201)
136139
expect(json_response['title']).to eq(message)
140+
expect(json_response['committer_name']).to eq(user.name)
141+
expect(json_response['committer_email']).to eq(user.email)
137142
end
138143

139144
it 'returns a 400 bad request if file exists' do

0 commit comments

Comments
 (0)