Fix for initial commit and remove unneeded args
This commit is contained in:
parent
ae86a1b9d3
commit
a30f278bde
3 changed files with 18 additions and 7 deletions
|
@ -4,9 +4,10 @@ module CreatesCommit
|
|||
def create_commit(service, success_path:, failure_path:, failure_view: nil, success_notice: nil)
|
||||
set_commit_variables
|
||||
|
||||
source_branch = @mr_target_branch unless initial_commit?
|
||||
commit_params = @commit_params.merge(
|
||||
source_project: @mr_target_project,
|
||||
source_branch: @mr_target_branch,
|
||||
source_branch: source_branch,
|
||||
target_branch: @mr_source_branch
|
||||
)
|
||||
|
||||
|
@ -113,7 +114,7 @@ module CreatesCommit
|
|||
else
|
||||
# Merge request to this project
|
||||
@mr_target_project = @project
|
||||
@mr_target_branch ||= @ref
|
||||
@mr_target_branch = @ref || @target_branch
|
||||
end
|
||||
else
|
||||
# Edit file in fork
|
||||
|
@ -121,7 +122,12 @@ module CreatesCommit
|
|||
# Merge request from fork to this project
|
||||
@mr_source_project = @tree_edit_project
|
||||
@mr_target_project = @project
|
||||
@mr_target_branch ||= @ref
|
||||
@mr_target_branch = @ref || @target_branch
|
||||
end
|
||||
end
|
||||
|
||||
def initial_commit?
|
||||
@mr_target_branch.nil? ||
|
||||
!@mr_target_project.repository.branch_exists?(@mr_target_branch)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,8 +26,15 @@ module Commits
|
|||
def commit_change(action)
|
||||
raise NotImplementedError unless repository.respond_to?(action)
|
||||
|
||||
into = @create_merge_request ? @commit.public_send("#{action}_branch_name") : @target_branch
|
||||
tree_id = repository.public_send("check_#{action}_content", @commit, @target_branch)
|
||||
if @create_merge_request
|
||||
into = @commit.public_send("#{action}_branch_name")
|
||||
tree_branch = @source_branch
|
||||
else
|
||||
into = tree_branch = @target_branch
|
||||
end
|
||||
|
||||
tree_id = repository.public_send(
|
||||
"check_#{action}_content", @commit, tree_branch)
|
||||
|
||||
if tree_id
|
||||
validate_target_branch(into) if @create_merge_request
|
||||
|
|
|
@ -140,8 +140,6 @@ module API
|
|||
commit_params = {
|
||||
commit: commit,
|
||||
create_merge_request: false,
|
||||
source_project: user_project,
|
||||
source_branch: commit.cherry_pick_branch_name,
|
||||
target_branch: params[:branch]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue