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:
		
							parent
							
								
									5e12b3d841
								
							
						
					
					
						commit
						ae86a1b9d3
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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?
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue