diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-15 21:44:15 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-23 23:37:43 +0300 |
commit | bc4fec1fcbf848bec682b59f2f47b1648eee9b44 (patch) | |
tree | e2f9e3f9512cb13b7c91a5a1e837dfd76b7ed06a | |
parent | 7c479d88a92233790bc0fb63146fe004f8b9b5d7 (diff) |
Remove @commit in compare and MR controllers
-rw-r--r-- | app/controllers/projects/compare_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 7 | ||||
-rw-r--r-- | app/models/merge_request_diff.rb | 3 |
3 files changed, 4 insertions, 11 deletions
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 7ec542bb2df..88dd600e5fe 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -51,12 +51,9 @@ class Projects::CompareController < Projects::ApplicationController if @compare @commits = @compare.commits - @start_commit = @compare.start_commit - @commit = @compare.commit - @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 @diff_notes_disabled = true diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index c8f68192f24..314906b5f09 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -14,7 +14,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ] 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_commit_vars, only: [:diffs] 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 :check_if_can_be_merged, only: :show @@ -130,8 +129,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController @diff_notes_disabled = true end - define_commit_vars - render_diff_for_path(@diffs) end @@ -500,10 +497,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController @notes = prepare_notes_for_rendering(@discussions.flat_map(&:notes)) end - def define_commit_vars - @commit = @merge_request.diff_head_commit - end - def define_diff_vars @merge_request_diff = if params[:diff_id] diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index a6f3994166b..6d6c561976c 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -159,6 +159,9 @@ class MergeRequestDiff < ActiveRecord::Base # It is not good enough for highlighting diffs, so we can't simply pass # these as `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 Gitlab::Diff::DiffRefs.new( |