Commit da9b009d31ee342d96da7b8796b937849de650cd

Authored by Sean Edge
Committed by Sean
1 parent 536b2f2f

Add fix for API when branch names have periods in them. Relates to issue #6128 …

…(https://github.com/gitlabhq/gitlabhq/issues/6128).
Showing 1 changed file with 7 additions and 3 deletions   Show diff stats
lib/api/branches.rb
@@ -24,7 +24,7 @@ module API @@ -24,7 +24,7 @@ module API
24 # branch (required) - The name of the branch 24 # branch (required) - The name of the branch
25 # Example Request: 25 # Example Request:
26 # GET /projects/:id/repository/branches/:branch 26 # GET /projects/:id/repository/branches/:branch
27 - get ":id/repository/branches/:branch" do 27 + get ':id/repository/branches/:branch', requirements: { branch: /.*/ } do
28 @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } 28 @branch = user_project.repo.heads.find { |item| item.name == params[:branch] }
29 not_found!("Branch does not exist") if @branch.nil? 29 not_found!("Branch does not exist") if @branch.nil?
30 present @branch, with: Entities::RepoObject, project: user_project 30 present @branch, with: Entities::RepoObject, project: user_project
@@ -37,7 +37,9 @@ module API @@ -37,7 +37,9 @@ module API
37 # branch (required) - The name of the branch 37 # branch (required) - The name of the branch
38 # Example Request: 38 # Example Request:
39 # PUT /projects/:id/repository/branches/:branch/protect 39 # PUT /projects/:id/repository/branches/:branch/protect
40 - put ":id/repository/branches/:branch/protect" do 40 + put ':id/repository/branches/:branch/protect',
  41 + requirements: { branch: /.*/ } do
  42 +
41 authorize_admin_project 43 authorize_admin_project
42 44
43 @branch = user_project.repository.find_branch(params[:branch]) 45 @branch = user_project.repository.find_branch(params[:branch])
@@ -55,7 +57,9 @@ module API @@ -55,7 +57,9 @@ module API
55 # branch (required) - The name of the branch 57 # branch (required) - The name of the branch
56 # Example Request: 58 # Example Request:
57 # PUT /projects/:id/repository/branches/:branch/unprotect 59 # PUT /projects/:id/repository/branches/:branch/unprotect
58 - put ":id/repository/branches/:branch/unprotect" do 60 + put ':id/repository/branches/:branch/unprotect',
  61 + requirements: { branch: /.*/ } do
  62 +
59 authorize_admin_project 63 authorize_admin_project
60 64
61 @branch = user_project.repository.find_branch(params[:branch]) 65 @branch = user_project.repository.find_branch(params[:branch])