diff options
author | Rémy Coutable <remy@rymai.me> | 2017-07-26 15:33:09 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-27 15:29:31 +0300 |
commit | 649382b1c27b09e5b54a5cdb21f078f37ecd7306 (patch) | |
tree | 870cd9927fdb61fe258d46976d4daf43ff5bda0b /lib | |
parent | 4eebd8e1957a3fc3a3479331fde9f34aa8afa9d5 (diff) |
Fix the /projects/:id/repository/branches endpoint to handle dots in the branch name when the project full patch contains a `/`
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/branches.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb index 3d816f8771d..cc81f3898ab 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -16,7 +16,7 @@ module API params do use :pagination end - get ":id/repository/branches" do + get ':id/repository/branches' do branches = ::Kaminari.paginate_array(user_project.repository.branches.sort_by(&:name)) present paginate(branches), with: Entities::RepoBranch, project: user_project @@ -28,7 +28,7 @@ module API params do requires :branch, type: String, desc: 'The name of the branch' end - get ':id/repository/branches/:branch', requirements: { branch: /.+/ } do + get ':id/repository/branches/:branch', requirements: { id: %r{[^/]+}, branch: %r{[^/]+} } do branch = user_project.repository.find_branch(params[:branch]) not_found!("Branch") unless branch @@ -46,7 +46,7 @@ module API optional :developers_can_push, type: Boolean, desc: 'Flag if developers can push to that branch' optional :developers_can_merge, type: Boolean, desc: 'Flag if developers can merge to that branch' end - put ':id/repository/branches/:branch/protect', requirements: { branch: /.+/ } do + put ':id/repository/branches/:branch/protect', requirements: { id: %r{[^/]+}, branch: %r{[^/]+} } do authorize_admin_project branch = user_project.repository.find_branch(params[:branch]) @@ -81,7 +81,7 @@ module API params do requires :branch, type: String, desc: 'The name of the branch' end - put ':id/repository/branches/:branch/unprotect', requirements: { branch: /.+/ } do + put ':id/repository/branches/:branch/unprotect', requirements: { id: %r{[^/]+}, branch: %r{[^/]+} } do authorize_admin_project branch = user_project.repository.find_branch(params[:branch]) @@ -99,7 +99,7 @@ module API requires :branch, 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 + post ':id/repository/branches' do authorize_push_project result = CreateBranchService.new(user_project, current_user) @@ -118,7 +118,7 @@ module API params do requires :branch, type: String, desc: 'The name of the branch' end - delete ":id/repository/branches/:branch", requirements: { branch: /.+/ } do + delete ':id/repository/branches/:branch', requirements: { id: %r{[^/]+}, branch: %r{[^/]+} } do authorize_push_project result = DeleteBranchService.new(user_project, current_user) @@ -130,7 +130,7 @@ module API end desc 'Delete all merged branches' - delete ":id/repository/merged_branches" do + delete ':id/repository/merged_branches' do DeleteMergedBranchesService.new(user_project, current_user).async_execute accepted! |