diff options
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/commits.rb | 29 | ||||
-rw-r--r-- | lib/api/entities.rb | 9 | ||||
-rw-r--r-- | lib/api/projects.rb | 18 |
3 files changed, 22 insertions, 34 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb deleted file mode 100644 index 47d96fc4906..00000000000 --- a/lib/api/commits.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Gitlab - # Commits API - class Commits < Grape::API - before { authenticate! } - - resource :projects do - # Get a list of project commits - # - # Parameters: - # id (required) - The ID or code name of a project - # ref_name (optional) - Name of branch or tag - # page (optional) - default is 0 - # per_page (optional) - default is 20 - # Example Request: - # GET /projects/:id/commits - get ":id/commits" do - authorize! :download_code, user_project - - page = params[:page] || 0 - per_page = params[:per_page] || 20 - ref = params[:ref_name] || user_project.try(:default_branch) || 'master' - - commits = user_project.commits(ref, nil, per_page, page * per_page) - - present CommitDecorator.decorate(commits), with: Entities::Commit - end - end - end -end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index fd19fa0e87f..ee6f15f1218 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -17,11 +17,6 @@ module Gitlab expose :id, :url end - class Commit < Grape::Entity - expose :id, :short_id, :title, - :author_name, :author_email, :created_at - end - class Project < Grape::Entity expose :id, :code, :name, :description, :path, :default_branch expose :owner, using: Entities::UserBasic @@ -39,6 +34,10 @@ module Gitlab expose :name, :commit end + class RepoCommit < Grape::Entity + expose :id, :short_id, :title, :author_name, :author_email, :created_at + end + class ProjectSnippet < Grape::Entity expose :id, :title, :file_name expose :author, using: Entities::UserBasic diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 0554d97c86b..c3dc3da6fac 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -211,6 +211,24 @@ module Gitlab present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject end + # Get a project repository commits + # + # Parameters: + # id (required) - The ID or code name of a project + # ref_name (optional) - The name of a repository branch or tag + # Example Request: + # GET /projects/:id/repository/commits + get ":id/repository/commits" do + authorize! :download_code, user_project + + page = params[:page] || 0 + per_page = params[:per_page] || 20 + ref = params[:ref_name] || user_project.try(:default_branch) || 'master' + + commits = user_project.commits(ref, nil, per_page, page * per_page) + present CommitDecorator.decorate(commits), with: Entities::RepoCommit + end + # Get a project snippet # # Parameters: |