diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-03 07:28:02 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-03 07:28:02 +0000 |
commit | 8031be73fede0718b81c1b9d038be8a7c81a946a (patch) | |
tree | 839e439cbe911df2991d2d772cfcf90ff03f0ef5 /lib | |
parent | efc6baf782951ea2150b45f524c103d0904dbdc1 (diff) | |
parent | dacf9f9f863dcb67a3dcb8dcfc4c151b10bca5e3 (diff) | |
download | gitlab-ce-8031be73fede0718b81c1b9d038be8a7c81a946a.tar.gz |
Merge branch 'contributors-api' into 'master'
Contributors api
Fixes #1266
See merge request !934
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/repositories.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/contributors.rb | 9 |
3 files changed, 25 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index b190646a1e3..09fb97abf29 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -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 diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index 03806d9343b..d091fa4f035 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -150,6 +150,18 @@ module API compare = Gitlab::Git::Compare.new(user_project.repository.raw_repository, params[:from], params[:to], MergeRequestDiff::COMMITS_SAFE_SIZE) present compare, with: Entities::Compare end + + # Get repository contributors + # + # Parameters: + # id (required) - The ID of a project + # Example Request: + # GET /projects/:id/repository/contributors + get ':id/repository/contributors' do + authorize! :download_code, user_project + + present user_project.repository.contributors, with: Entities::Contributor + end end end end diff --git a/lib/gitlab/contributors.rb b/lib/gitlab/contributors.rb new file mode 100644 index 00000000000..c41e92b620f --- /dev/null +++ b/lib/gitlab/contributors.rb @@ -0,0 +1,9 @@ +module Gitlab + class Contributor + attr_accessor :email, :name, :commits, :additions, :deletions + + def initialize + @commits, @additions, @deletions = 0, 0, 0 + end + end +end |