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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
767bd780
Commit
767bd780
authored
Jul 02, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Contributor class instead of hash
parent
5a88873e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
17 deletions
+16
-17
app/models/repository.rb
app/models/repository.rb
+10
-15
lib/api/entities.rb
lib/api/entities.rb
+4
-0
lib/api/repositories.rb
lib/api/repositories.rb
+1
-1
lib/gitlab/contributors.rb
lib/gitlab/contributors.rb
+1
-1
No files found.
app/models/repository.rb
View file @
767bd780
...
...
@@ -244,28 +244,23 @@ class Repository
end
def
contributors
contributors
=
{}
log
=
graph_log
.
group_by
{
|
i
|
i
[
:author_email
]
}
log
.
each
do
|
email
,
contributions
|
contributors
[
email
]
=
{
email:
email
,
commits:
0
,
additions:
0
,
deletions:
0
,
}
log
.
map
do
|
email
,
contributions
|
contributor
=
Gitlab
::
Contributor
.
new
contributor
.
email
=
email
contributions
.
each
do
|
contribution
|
if
contributor
s
[
email
][
:name
]
.
blank?
contributor
s
[
email
][
:name
]
=
contribution
[
:author_name
]
if
contributor
.
name
.
blank?
contributor
.
name
=
contribution
[
:author_name
]
end
contributor
s
[
email
][
:commits
]
+=
1
contributor
s
[
email
][
:additions
]
+=
contribution
[
:additions
]
||
0
contributor
s
[
email
][
:deletions
]
+=
contribution
[
:deletions
]
||
0
contributor
.
commits
+=
1
contributor
.
additions
+=
contribution
[
:additions
]
||
0
contributor
.
deletions
+=
contribution
[
:deletions
]
||
0
end
end
contributors
.
values
contributor
end
end
end
lib/api/entities.rb
View file @
767bd780
...
...
@@ -218,5 +218,9 @@ module API
expose
:same
,
as: :compare_same_ref
end
class
Contributor
<
Grape
::
Entity
expose
:name
,
:email
,
:commits
,
:additions
,
:deletions
end
end
end
lib/api/repositories.rb
View file @
767bd780
...
...
@@ -160,7 +160,7 @@ module API
get
':id/repository/contributors'
do
authorize!
:download_code
,
user_project
user_project
.
repository
.
contributors
present
user_project
.
repository
.
contributors
,
with:
Entities
::
Contributor
end
end
end
...
...
lib/gitlab/contributors.rb
View file @
767bd780
...
...
@@ -3,7 +3,7 @@ module Gitlab
attr_accessor
:email
,
:name
,
:commits
,
:additions
,
:deletions
def
initialize
@commits
,
@additions
,
@deletions
=
0
,
0
,
0
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