diff options
author | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2012-09-21 13:22:30 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2012-09-21 13:22:30 +0300 |
commit | 10d3a30b255cd85b2cf7af39814fd7418eecd838 (patch) | |
tree | 1082a03374c7130ad33f9136d0d41f979bfe603c /lib/api/commits.rb | |
parent | 4cc169d3cacea7e4325bb5632cc8878a7c3f41fe (diff) | |
download | gitlab-ce-10d3a30b255cd85b2cf7af39814fd7418eecd838.tar.gz |
APi for commits. Better api docs
Diffstat (limited to 'lib/api/commits.rb')
-rw-r--r-- | lib/api/commits.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb new file mode 100644 index 00000000000..47d96fc4906 --- /dev/null +++ b/lib/api/commits.rb @@ -0,0 +1,29 @@ +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 |