#671: added Projects#refs_list API action

This commit is contained in:
Vokhmin Alexey V 2012-10-11 20:27:17 +04:00
parent 6b3bf41c7a
commit 8f3ed58cd8
3 changed files with 16 additions and 2 deletions

View File

@ -2,7 +2,7 @@
class Api::V1::ProjectsController < Api::V1::BaseController class Api::V1::ProjectsController < Api::V1::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:get_id, :show] if APP_CONFIG['anonymous_access'] skip_before_filter :authenticate_user!, :only => [:get_id, :show, :refs] if APP_CONFIG['anonymous_access']
load_and_authorize_resource load_and_authorize_resource
@ -15,6 +15,9 @@ class Api::V1::ProjectsController < Api::V1::BaseController
end end
def show def show
end end
def refs_list
end
end end

View File

@ -0,0 +1,8 @@
json.refs_list (@project.repo.branches + @project.repo.tags) do |json_grit, grit|
json_grit.ref grit.name
json_grit.object do |json_object|
json_object.type (grit.class.name =~ /Tag/ ? 'tag' : 'commit')
json_object.sha grit.commit.id
end
end
json.url refs_list_api_v1_project_path(@project.id, :format => :json)

View File

@ -35,6 +35,9 @@ Rosa::Application.routes.draw do
resources :repositories, :only => [:show] resources :repositories, :only => [:show]
resources :projects, :only => [:show] do resources :projects, :only => [:show] do
collection { get :get_id } collection { get :get_id }
member {
get :refs_list
}
end end
end end
end end