Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
81d41c0f
Commit
81d41c0f
authored
Jul 02, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collect contributors info via API
parent
2e3818f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
lib/api/repositories.rb
lib/api/repositories.rb
+22
-0
spec/requests/api/repositories_spec.rb
spec/requests/api/repositories_spec.rb
+14
-1
No files found.
lib/api/repositories.rb
View file @
81d41c0f
...
@@ -160,7 +160,29 @@ module API
...
@@ -160,7 +160,29 @@ module API
get
':id/repository/contributors'
do
get
':id/repository/contributors'
do
authorize!
:download_code
,
user_project
authorize!
:download_code
,
user_project
contributors
=
{}
contributors
log
=
user_project
.
repository
.
graph_log
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
end
end
end
...
...
spec/requests/api/repositories_spec.rb
View file @
81d41c0f
...
@@ -128,7 +128,7 @@ describe API::API, api: true do
...
@@ -128,7 +128,7 @@ describe API::API, api: true do
end
end
end
end
describe
'GET /
GET /
projects/:id/repository/compare'
do
describe
'GET /projects/:id/repository/compare'
do
it
"should compare branches"
do
it
"should compare branches"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'master'
,
to:
'simple_merge_request'
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'master'
,
to:
'simple_merge_request'
response
.
status
.
should
==
200
response
.
status
.
should
==
200
...
@@ -166,4 +166,17 @@ describe API::API, api: true do
...
@@ -166,4 +166,17 @@ describe API::API, api: true do
json_response
[
'compare_same_ref'
].
should
be_true
json_response
[
'compare_same_ref'
].
should
be_true
end
end
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
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment