summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-08-04 19:18:07 +0200
committerDouwe Maan <douwe@selenight.nl>2017-08-04 19:18:07 +0200
commitd41479266d16facdce08974ef76f3fb7539a1530 (patch)
treeb41245c96a85968bde0a65d66328aecbd99031c0 /lib/api
parentc41f64d7ff8ddcc47e0ab269accc33b4a2653a22 (diff)
downloadgitlab-ce-d41479266d16facdce08974ef76f3fb7539a1530.tar.gz
Add start_branch to files and commits APIs
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/commits.rb6
-rw-r--r--lib/api/files.rb7
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb
index bcb842b9211..bc9f5d93ec1 100644
--- a/lib/api/commits.rb
+++ b/lib/api/commits.rb
@@ -53,16 +53,18 @@ module API
detail 'This feature was introduced in GitLab 8.13'
end
params do
- requires :branch, type: String, desc: 'The name of branch'
+ requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.'
requires :commit_message, type: String, desc: 'Commit message'
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 :author_email, type: String, desc: 'Author email for commit'
optional :author_name, type: String, desc: 'Author name for commit'
end
post ":id/repository/commits" do
authorize! :push_code, user_project
- attrs = declared_params.merge(start_branch: declared_params[:branch], branch_name: declared_params[:branch])
+ attrs[:branch_name] = declared_params.delete(:branch)
+ attrs[:start_branch] ||= attrs[:branch_name]
result = ::Files::MultiService.new(user_project, current_user, attrs).execute
diff --git a/lib/api/files.rb b/lib/api/files.rb
index 521287ee2b4..450334fee84 100644
--- a/lib/api/files.rb
+++ b/lib/api/files.rb
@@ -4,7 +4,7 @@ module API
def commit_params(attrs)
{
file_path: attrs[:file_path],
- start_branch: attrs[:branch],
+ start_branch: attrs[:start_branch] || attrs[:branch],
branch_name: attrs[:branch],
commit_message: attrs[:commit_message],
file_content: attrs[:content],
@@ -37,8 +37,9 @@ module API
params :simple_file_params do
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
- requires :branch, type: String, desc: 'The name of branch'
- requires :commit_message, type: String, desc: 'Commit Message'
+ requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.'
+ requires :commit_message, type: String, desc: 'Commit message'
+ 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_name, type: String, desc: 'The name of the author'
end