From 63360adeae3ba5b302b711c73b6439956d274cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 15 Mar 2017 19:09:24 +0100 Subject: Add `requirements: { id: %r{[^/]+} }` for all projects and groups namespaced API routes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- lib/api/v3/branches.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/v3/branches.rb') diff --git a/lib/api/v3/branches.rb b/lib/api/v3/branches.rb index 699e41b5537..7d9d6246e46 100644 --- a/lib/api/v3/branches.rb +++ b/lib/api/v3/branches.rb @@ -9,7 +9,7 @@ module API params do requires :id, type: String, desc: 'The ID of a project' end - resource :projects do + resource :projects, requirements: { id: %r{[^/]+} } do desc 'Get a project repository branches' do success ::API::Entities::RepoBranch end -- cgit v1.2.1 From 3f111741967a5dcb6e0418471d2b26ca9ab04eac Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Thu, 16 Mar 2017 21:15:05 -0300 Subject: Use "branch_name" instead "branch" on V3 branch creation API --- lib/api/v3/branches.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/api/v3/branches.rb') diff --git a/lib/api/v3/branches.rb b/lib/api/v3/branches.rb index 7d9d6246e46..0a877b960f6 100644 --- a/lib/api/v3/branches.rb +++ b/lib/api/v3/branches.rb @@ -45,6 +45,27 @@ module API status(200) end + + desc 'Create branch' do + success ::API::Entities::RepoBranch + end + params do + requires :branch_name, type: String, desc: 'The name of the branch' + requires :ref, type: String, desc: 'Create branch from commit sha or existing branch' + end + post ":id/repository/branches" do + authorize_push_project + result = CreateBranchService.new(user_project, current_user). + execute(params[:branch_name], params[:ref]) + + if result[:status] == :success + present result[:branch], + with: ::API::Entities::RepoBranch, + project: user_project + else + render_api_error!(result[:message], 400) + end + end end end end -- cgit v1.2.1