BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
17 deletions
+16
-17
repository.rb
app/models/repository.rb
+10
-15
entities.rb
lib/api/entities.rb
+4
-0
repositories.rb
lib/api/repositories.rb
+1
-1
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