Just trust set_commit_variables to set everything!

Removing those weird setup in assign_change_commit_vars
fixed all the failures in the tests. I still cannot say
why but clearly we need to have better names. It's so
confusing right now. We should seriously stop fiddling
those instance variables.
This commit is contained in:
Lin Jen-Shin 2017-01-06 02:11:27 +08:00
parent 5e12b3d841
commit ae86a1b9d3
3 changed files with 6 additions and 9 deletions

View File

@ -4,11 +4,9 @@ module CreatesCommit
def create_commit(service, success_path:, failure_path:, failure_view: nil, success_notice: nil)
set_commit_variables
source_branch = @ref if
@ref && @mr_target_project.repository.branch_exists?(@ref)
commit_params = @commit_params.merge(
source_project: @mr_target_project,
source_branch: source_branch,
source_branch: @mr_target_branch,
target_branch: @mr_source_branch
)

View File

@ -40,7 +40,7 @@ class Projects::CommitController < Projects::ApplicationController
end
def revert
assign_change_commit_vars(@commit.revert_branch_name)
assign_change_commit_vars
return render_404 if @target_branch.blank?
@ -49,7 +49,7 @@ class Projects::CommitController < Projects::ApplicationController
end
def cherry_pick
assign_change_commit_vars(@commit.cherry_pick_branch_name)
assign_change_commit_vars
return render_404 if @target_branch.blank?
@ -110,11 +110,9 @@ class Projects::CommitController < Projects::ApplicationController
@ci_pipelines = project.pipelines.where(sha: commit.sha)
end
def assign_change_commit_vars(mr_source_branch)
def assign_change_commit_vars
@commit = project.commit(params[:id])
@target_branch = params[:target_branch]
@mr_source_branch = mr_source_branch
@mr_target_branch = @target_branch
@commit_params = {
commit: @commit,
create_merge_request: params[:create_merge_request].present? || different_project?

View File

@ -5,6 +5,7 @@ module Commits
def execute
@source_project = params[:source_project] || @project
@source_branch = params[:source_branch]
@target_branch = params[:target_branch]
@commit = params[:commit]
@create_merge_request = params[:create_merge_request].present?
@ -38,7 +39,7 @@ module Commits
into,
tree_id,
source_project: @source_project,
source_branch_name: @target_branch)
source_branch_name: @source_branch)
success
else