diff options
author | Kerri Miller <kerrizor@kerrizor.com> | 2019-05-31 14:21:15 +0000 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2019-05-31 14:21:15 +0000 |
commit | 35c37fb29343974bf2edc3959d6a21db9c384307 (patch) | |
tree | e5f0065b8b9347c3920190e476e5ba816497c23f /lib/api/commits.rb | |
parent | 9a8955d3c06c23cfc95914254ec77cc78e2cf6b5 (diff) | |
download | gitlab-ce-35c37fb29343974bf2edc3959d6a21db9c384307.tar.gz |
Add optional param :start_project to allow variable commit targets
This extends POST#:id/repository/commits to allow the optional parameter
`:start_project`, which will allow targeting other projects besides the
one derived from `:id`.
Resolves https://gitlab.com/gitlab-org/gitlab-ce/issues/50850
Diffstat (limited to 'lib/api/commits.rb')
-rw-r--r-- | lib/api/commits.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb index 65eb9bfb87e..80913f4ca07 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -96,17 +96,27 @@ module API end end optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from' + optional :start_project, types: [Integer, String], desc: 'The ID or path of the project to start the commit from' optional :author_email, type: String, desc: 'Author email for commit' optional :author_name, type: String, desc: 'Author name for commit' optional :stats, type: Boolean, default: true, desc: 'Include commit stats' optional :force, type: Boolean, default: false, desc: 'When `true` overwrites the target branch with a new commit based on the `start_branch`' end post ':id/repository/commits' do + if params[:start_project] + start_project = find_project!(params[:start_project]) + + unless user_project.forked_from?(start_project) + forbidden!("Project is not included in the fork network for #{start_project.full_name}") + end + end + authorize_push_to_branch!(params[:branch]) attrs = declared_params attrs[:branch_name] = attrs.delete(:branch) attrs[:start_branch] ||= attrs[:branch_name] + attrs[:start_project] = start_project if start_project result = ::Files::MultiService.new(user_project, current_user, attrs).execute |