Commit bc4fec1f authored by Douwe Maan's avatar Douwe Maan

Remove @commit in compare and MR controllers

parent 7c479d88
...@@ -51,12 +51,9 @@ class Projects::CompareController < Projects::ApplicationController ...@@ -51,12 +51,9 @@ class Projects::CompareController < Projects::ApplicationController
if @compare if @compare
@commits = @compare.commits @commits = @compare.commits
@start_commit = @compare.start_commit
@commit = @compare.commit
@diffs = @compare.diffs(diff_options) @diffs = @compare.diffs(diff_options)
environment_params = @repository.branch_exists?(@head_ref) ? { ref: @head_ref } : { commit: @commit } environment_params = @repository.branch_exists?(@head_ref) ? { ref: @head_ref } : { commit: @compare.commit }
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last @environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
@diff_notes_disabled = true @diff_notes_disabled = true
......
...@@ -14,7 +14,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -14,7 +14,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
] ]
before_action :validates_merge_request, only: [:show, :diffs, :commits, :pipelines] before_action :validates_merge_request, only: [:show, :diffs, :commits, :pipelines]
before_action :define_show_vars, only: [:diffs, :commits, :conflicts, :conflict_for_path, :builds, :pipelines] before_action :define_show_vars, only: [:diffs, :commits, :conflicts, :conflict_for_path, :builds, :pipelines]
before_action :define_commit_vars, only: [:diffs]
before_action :ensure_ref_fetched, only: [:show, :diffs, :commits, :builds, :conflicts, :conflict_for_path, :pipelines] before_action :ensure_ref_fetched, only: [:show, :diffs, :commits, :builds, :conflicts, :conflict_for_path, :pipelines]
before_action :close_merge_request_without_source_project, only: [:show, :diffs, :commits, :builds, :pipelines] before_action :close_merge_request_without_source_project, only: [:show, :diffs, :commits, :builds, :pipelines]
before_action :check_if_can_be_merged, only: :show before_action :check_if_can_be_merged, only: :show
...@@ -130,8 +129,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -130,8 +129,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@diff_notes_disabled = true @diff_notes_disabled = true
end end
define_commit_vars
render_diff_for_path(@diffs) render_diff_for_path(@diffs)
end end
...@@ -500,10 +497,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -500,10 +497,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@notes = prepare_notes_for_rendering(@discussions.flat_map(&:notes)) @notes = prepare_notes_for_rendering(@discussions.flat_map(&:notes))
end end
def define_commit_vars
@commit = @merge_request.diff_head_commit
end
def define_diff_vars def define_diff_vars
@merge_request_diff = @merge_request_diff =
if params[:diff_id] if params[:diff_id]
......
...@@ -159,6 +159,9 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -159,6 +159,9 @@ class MergeRequestDiff < ActiveRecord::Base
# It is not good enough for highlighting diffs, so we can't simply pass # It is not good enough for highlighting diffs, so we can't simply pass
# these as `diff_refs.` # these as `diff_refs.`
def fallback_diff_refs def fallback_diff_refs
real_refs = diff_refs
return real_refs if real_refs
likely_base_commit_sha = (first_commit&.parent || first_commit)&.sha likely_base_commit_sha = (first_commit&.parent || first_commit)&.sha
Gitlab::Diff::DiffRefs.new( Gitlab::Diff::DiffRefs.new(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment