Skip to content
Snippets Groups Projects
Commit 81d41c0f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Collect contributors info via API

parent 2e3818f1
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -160,7 +160,29 @@ module API
get ':id/repository/contributors' do
authorize! :download_code, user_project
 
contributors = {}
contributors
log = user_project.repository.graph_log
log.each do |entry|
email = entry[:author_email].to_s
if contributors.has_key?(email)
contributors[email][:commits] += 1
contributors[email][:additions] += entry[:additions] || 0
contributors[email][:deletions] += entry[:deletions] || 0
else
contributors[email] = {
email: email,
name: entry[:author_name],
commits: 1,
additions: entry[:additions] || 0,
deletions: entry[:deletions] || 0,
}
end
end
contributors
end
end
end
Loading
Loading
Loading
Loading
@@ -128,7 +128,7 @@ describe API::API, api: true do
end
end
 
describe 'GET /GET /projects/:id/repository/compare' do
describe 'GET /projects/:id/repository/compare' do
it "should compare branches" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'simple_merge_request'
response.status.should == 200
Loading
Loading
@@ -166,4 +166,17 @@ describe API::API, api: true do
json_response['compare_same_ref'].should be_true
end
end
describe 'GET /projects/:id/repository/contributors' do
it 'should return valid data' do
get api("/projects/#{project.id}/repository/contributors", user)
response.status.should == 200
contributor = json_response.values.first
contributor['email'].should == 'dmitriy.zaporozhets@gmail.com'
contributor['name'].should == 'Dmitriy Zaporozhets'
contributor['commits'].should == 185
contributor['additions'].should == 66072
contributor['deletions'].should == 63013
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment