summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-12-04 12:17:07 +0000
committerRémy Coutable <remy@rymai.me>2016-12-04 12:17:07 +0000
commitbd67459131e22273b502eb27d97709827ff42262 (patch)
treebe9f7895077833da2ee8f6446fc944d7addaecdd
parent0819d093e9b4aa9d5af1f6bdde147462f0c7cb48 (diff)
parent79d99d470faf5cf088a0b76ae6bb2ec280c4c4a8 (diff)
downloadgitlab-ce-bd67459131e22273b502eb27d97709827ff42262.tar.gz
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
-rw-r--r--changelogs/unreleased/api-expose-commiter-details.yml4
-rw-r--r--doc/api/commits.md8
-rw-r--r--lib/api/entities.rb1
-rw-r--r--spec/requests/api/commits_spec.rb9
4 files changed, 20 insertions, 2 deletions
diff --git a/changelogs/unreleased/api-expose-commiter-details.yml b/changelogs/unreleased/api-expose-commiter-details.yml
new file mode 100644
index 00000000000..5ee34adc5c9
--- /dev/null
+++ b/changelogs/unreleased/api-expose-commiter-details.yml
@@ -0,0 +1,4 @@
+---
+title: 'API: Expose committer details for commits'
+merge_request:
+author: Robert Schilling
diff --git a/doc/api/commits.md b/doc/api/commits.md
index e1ed99d98d3..0170af00e0e 100644
--- a/doc/api/commits.md
+++ b/doc/api/commits.md
@@ -29,6 +29,8 @@ Example response:
"title": "Replace sanitize with escape once",
"author_name": "Dmitriy Zaporozhets",
"author_email": "dzaporozhets@sphereconsultinginc.com",
+ "committer_name": "Administrator",
+ "committer_email": "admin@example.com",
"created_at": "2012-09-20T11:50:22+03:00",
"message": "Replace sanitize with escape once",
"allow_failure": false
@@ -39,6 +41,8 @@ Example response:
"title": "Sanitize for network graph",
"author_name": "randx",
"author_email": "dmitriy.zaporozhets@gmail.com",
+ "committer_name": "Dmitriy",
+ "committer_email": "dmitriy.zaporozhets@gmail.com",
"created_at": "2012-09-20T09:06:12+03:00",
"message": "Sanitize for network graph",
"allow_failure": false
@@ -115,6 +119,8 @@ Example response:
"title": "some commit message",
"author_name": "Dmitriy Zaporozhets",
"author_email": "dzaporozhets@sphereconsultinginc.com",
+ "committer_name": "Dmitriy Zaporozhets",
+ "committer_email": "dzaporozhets@sphereconsultinginc.com",
"created_at": "2016-09-20T09:26:24.000-07:00",
"message": "some commit message",
"parent_ids": [
@@ -159,6 +165,8 @@ Example response:
"title": "Sanitize for network graph",
"author_name": "randx",
"author_email": "dmitriy.zaporozhets@gmail.com",
+ "committer_name": "Dmitriy",
+ "committer_email": "dmitriy.zaporozhets@gmail.com",
"created_at": "2012-09-20T09:06:12+03:00",
"message": "Sanitize for network graph",
"committed_date": "2012-09-20T09:06:12+03:00",
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index d5dfb8d00be..899d68bc6c7 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -174,6 +174,7 @@ module API
class RepoCommit < Grape::Entity
expose :id, :short_id, :title, :author_name, :author_email, :created_at
+ expose :committer_name, :committer_email
expose :safe_message, as: :message
end
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index 52491e1b9ed..e497bce6943 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -18,11 +18,14 @@ describe API::Commits, api: true do
before { project.team << [user2, :reporter] }
it "returns project commits" do
+ commit = project.repository.commit
get api("/projects/#{project.id}/repository/commits", user)
- expect(response).to have_http_status(200)
+ expect(response).to have_http_status(200)
expect(json_response).to be_an Array
- expect(json_response.first['id']).to eq(project.repository.commit.id)
+ expect(json_response.first['id']).to eq(commit.id)
+ expect(json_response.first['committer_name']).to eq(commit.committer_name)
+ expect(json_response.first['committer_email']).to eq(commit.committer_email)
end
end
@@ -134,6 +137,8 @@ describe API::Commits, api: true do
expect(response).to have_http_status(201)
expect(json_response['title']).to eq(message)
+ expect(json_response['committer_name']).to eq(user.name)
+ expect(json_response['committer_email']).to eq(user.email)
end
it 'returns a 400 bad request if file exists' do