Commit cb20ab02 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #6929 from asedge/fix_api_branches_with_periods

Add fix for API when branch names have periods in them.  Relates to issu...
parents 4d11a3d8 da9b009d
...@@ -24,7 +24,7 @@ module API ...@@ -24,7 +24,7 @@ module API
# branch (required) - The name of the branch # branch (required) - The name of the branch
# Example Request: # Example Request:
# GET /projects/:id/repository/branches/:branch # GET /projects/:id/repository/branches/:branch
get ":id/repository/branches/:branch" do get ':id/repository/branches/:branch', requirements: { branch: /.*/ } do
@branch = user_project.repo.heads.find { |item| item.name == params[:branch] } @branch = user_project.repo.heads.find { |item| item.name == params[:branch] }
not_found!("Branch does not exist") if @branch.nil? not_found!("Branch does not exist") if @branch.nil?
present @branch, with: Entities::RepoObject, project: user_project present @branch, with: Entities::RepoObject, project: user_project
...@@ -37,7 +37,9 @@ module API ...@@ -37,7 +37,9 @@ module API
# branch (required) - The name of the branch # branch (required) - The name of the branch
# Example Request: # Example Request:
# PUT /projects/:id/repository/branches/:branch/protect # PUT /projects/:id/repository/branches/:branch/protect
put ":id/repository/branches/:branch/protect" do put ':id/repository/branches/:branch/protect',
requirements: { branch: /.*/ } do
authorize_admin_project authorize_admin_project
@branch = user_project.repository.find_branch(params[:branch]) @branch = user_project.repository.find_branch(params[:branch])
...@@ -55,7 +57,9 @@ module API ...@@ -55,7 +57,9 @@ module API
# branch (required) - The name of the branch # branch (required) - The name of the branch
# Example Request: # Example Request:
# PUT /projects/:id/repository/branches/:branch/unprotect # PUT /projects/:id/repository/branches/:branch/unprotect
put ":id/repository/branches/:branch/unprotect" do put ':id/repository/branches/:branch/unprotect',
requirements: { branch: /.*/ } do
authorize_admin_project authorize_admin_project
@branch = user_project.repository.find_branch(params[:branch]) @branch = user_project.repository.find_branch(params[:branch])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment