Resolve "500 Internal Server Error: Cherrypick commit with empty branch name"
This commit is contained in:
parent
099e404a2b
commit
f2747f1ce0
7 changed files with 27 additions and 14 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Fixes 500 for cherry pick API with empty branch name
|
||||||
|
merge_request: 21501
|
||||||
|
author: Jacopo Beschi @jacopo-beschi
|
||||||
|
type: fixed
|
|
@ -69,7 +69,7 @@ module API
|
||||||
success Entities::Branch
|
success Entities::Branch
|
||||||
end
|
end
|
||||||
params do
|
params do
|
||||||
requires :branch, type: String, desc: 'The name of the branch'
|
requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
|
||||||
optional :developers_can_push, type: Boolean, desc: 'Flag if developers can push to that branch'
|
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'
|
optional :developers_can_merge, type: Boolean, desc: 'Flag if developers can merge to that branch'
|
||||||
end
|
end
|
||||||
|
@ -106,7 +106,7 @@ module API
|
||||||
success Entities::Branch
|
success Entities::Branch
|
||||||
end
|
end
|
||||||
params do
|
params do
|
||||||
requires :branch, type: String, desc: 'The name of the branch'
|
requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
|
||||||
end
|
end
|
||||||
put ':id/repository/branches/:branch/unprotect', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
|
put ':id/repository/branches/:branch/unprotect', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
|
||||||
authorize_admin_project
|
authorize_admin_project
|
||||||
|
@ -122,8 +122,8 @@ module API
|
||||||
success Entities::Branch
|
success Entities::Branch
|
||||||
end
|
end
|
||||||
params do
|
params do
|
||||||
requires :branch, type: String, desc: 'The name of the branch'
|
requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
|
||||||
requires :ref, type: String, desc: 'Create branch from commit sha or existing branch'
|
requires :ref, type: String, desc: 'Create branch from commit sha or existing branch', allow_blank: false
|
||||||
end
|
end
|
||||||
post ':id/repository/branches' do
|
post ':id/repository/branches' do
|
||||||
authorize_push_project
|
authorize_push_project
|
||||||
|
@ -143,7 +143,7 @@ module API
|
||||||
|
|
||||||
desc 'Delete a branch'
|
desc 'Delete a branch'
|
||||||
params do
|
params do
|
||||||
requires :branch, type: String, desc: 'The name of the branch'
|
requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
|
||||||
end
|
end
|
||||||
delete ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
|
delete ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
|
||||||
authorize_push_project
|
authorize_push_project
|
||||||
|
|
|
@ -71,7 +71,7 @@ module API
|
||||||
detail 'This feature was introduced in GitLab 8.13'
|
detail 'This feature was introduced in GitLab 8.13'
|
||||||
end
|
end
|
||||||
params do
|
params do
|
||||||
requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.'
|
requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.', allow_blank: false
|
||||||
requires :commit_message, type: String, desc: 'Commit message'
|
requires :commit_message, type: String, desc: 'Commit message'
|
||||||
requires :actions, type: Array[Hash], desc: 'Actions to perform in commit'
|
requires :actions, type: Array[Hash], desc: 'Actions to perform in commit'
|
||||||
optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from'
|
optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from'
|
||||||
|
@ -151,7 +151,7 @@ module API
|
||||||
end
|
end
|
||||||
params do
|
params do
|
||||||
requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag to be cherry picked'
|
requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag to be cherry picked'
|
||||||
requires :branch, type: String, desc: 'The name of the branch'
|
requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
|
||||||
end
|
end
|
||||||
post ':id/repository/commits/:sha/cherry_pick', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
|
post ':id/repository/commits/:sha/cherry_pick', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
|
||||||
authorize_push_to_branch!(params[:branch])
|
authorize_push_to_branch!(params[:branch])
|
||||||
|
|
|
@ -58,7 +58,7 @@ module API
|
||||||
|
|
||||||
params :simple_file_params do
|
params :simple_file_params do
|
||||||
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
||||||
requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.'
|
requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.', allow_blank: false
|
||||||
requires :commit_message, type: String, allow_blank: false, desc: 'Commit message'
|
requires :commit_message, type: String, allow_blank: false, desc: 'Commit message'
|
||||||
optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from'
|
optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from'
|
||||||
optional :author_email, type: String, desc: 'The email of the author'
|
optional :author_email, type: String, desc: 'The email of the author'
|
||||||
|
@ -80,7 +80,7 @@ module API
|
||||||
desc 'Get raw file metadata from repository'
|
desc 'Get raw file metadata from repository'
|
||||||
params do
|
params do
|
||||||
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
||||||
requires :ref, type: String, desc: 'The name of branch, tag or commit'
|
requires :ref, type: String, desc: 'The name of branch, tag or commit', allow_blank: false
|
||||||
end
|
end
|
||||||
head ":id/repository/files/:file_path/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do
|
head ":id/repository/files/:file_path/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do
|
||||||
assign_file_vars!
|
assign_file_vars!
|
||||||
|
@ -91,7 +91,7 @@ module API
|
||||||
desc 'Get raw file contents from the repository'
|
desc 'Get raw file contents from the repository'
|
||||||
params do
|
params do
|
||||||
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
||||||
requires :ref, type: String, desc: 'The name of branch, tag commit'
|
requires :ref, type: String, desc: 'The name of branch, tag commit', allow_blank: false
|
||||||
end
|
end
|
||||||
get ":id/repository/files/:file_path/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do
|
get ":id/repository/files/:file_path/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do
|
||||||
assign_file_vars!
|
assign_file_vars!
|
||||||
|
@ -104,7 +104,7 @@ module API
|
||||||
desc 'Get file metadata from repository'
|
desc 'Get file metadata from repository'
|
||||||
params do
|
params do
|
||||||
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
||||||
requires :ref, type: String, desc: 'The name of branch, tag or commit'
|
requires :ref, type: String, desc: 'The name of branch, tag or commit', allow_blank: false
|
||||||
end
|
end
|
||||||
head ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do
|
head ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do
|
||||||
assign_file_vars!
|
assign_file_vars!
|
||||||
|
@ -115,7 +115,7 @@ module API
|
||||||
desc 'Get a file from the repository'
|
desc 'Get a file from the repository'
|
||||||
params do
|
params do
|
||||||
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
|
||||||
requires :ref, type: String, desc: 'The name of branch, tag or commit'
|
requires :ref, type: String, desc: 'The name of branch, tag or commit', allow_blank: false
|
||||||
end
|
end
|
||||||
get ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do
|
get ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do
|
||||||
assign_file_vars!
|
assign_file_vars!
|
||||||
|
|
|
@ -39,7 +39,7 @@ module API
|
||||||
end
|
end
|
||||||
params do
|
params do
|
||||||
requires :description, type: String, desc: 'The description of pipeline schedule'
|
requires :description, type: String, desc: 'The description of pipeline schedule'
|
||||||
requires :ref, type: String, desc: 'The branch/tag name will be triggered'
|
requires :ref, type: String, desc: 'The branch/tag name will be triggered', allow_blank: false
|
||||||
requires :cron, type: String, desc: 'The cron'
|
requires :cron, type: String, desc: 'The cron'
|
||||||
optional :cron_timezone, type: String, default: 'UTC', desc: 'The timezone'
|
optional :cron_timezone, type: String, default: 'UTC', desc: 'The timezone'
|
||||||
optional :active, type: Boolean, default: true, desc: 'The activation of pipeline schedule'
|
optional :active, type: Boolean, default: true, desc: 'The activation of pipeline schedule'
|
||||||
|
|
|
@ -10,7 +10,7 @@ module API
|
||||||
success Entities::Pipeline
|
success Entities::Pipeline
|
||||||
end
|
end
|
||||||
params do
|
params do
|
||||||
requires :ref, type: String, desc: 'The commit sha or name of a branch or tag'
|
requires :ref, type: String, desc: 'The commit sha or name of a branch or tag', allow_blank: false
|
||||||
requires :token, type: String, desc: 'The unique token of trigger'
|
requires :token, type: String, desc: 'The unique token of trigger'
|
||||||
optional :variables, type: Hash, desc: 'The list of variables to be injected into build'
|
optional :variables, type: Hash, desc: 'The list of variables to be injected into build'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1040,6 +1040,14 @@ describe API::Commits do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when branch is empty' do
|
||||||
|
['', ' '].each do |branch|
|
||||||
|
it_behaves_like '400 response' do
|
||||||
|
let(:request) { post api(route, current_user), branch: branch }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when branch does not exist' do
|
context 'when branch does not exist' do
|
||||||
it_behaves_like '404 response' do
|
it_behaves_like '404 response' do
|
||||||
let(:request) { post api(route, current_user), branch: 'foo' }
|
let(:request) { post api(route, current_user), branch: 'foo' }
|
||||||
|
|
Loading…
Reference in a new issue