diff options
Diffstat (limited to 'app/controllers/projects/merge_requests')
-rw-r--r-- | app/controllers/projects/merge_requests/application_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests/diffs_controller.rb | 34 |
2 files changed, 23 insertions, 17 deletions
diff --git a/app/controllers/projects/merge_requests/application_controller.rb b/app/controllers/projects/merge_requests/application_controller.rb index d8da448a323..be44c78ac9d 100644 --- a/app/controllers/projects/merge_requests/application_controller.rb +++ b/app/controllers/projects/merge_requests/application_controller.rb @@ -5,7 +5,7 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont before_action :merge_request before_action :authorize_read_merge_request! - feature_category :code_review + feature_category :code_review_workflow private @@ -13,6 +13,10 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont @issuable = @merge_request ||= merge_request_includes(@project.merge_requests).find_by_iid!(params[:id]) + + return render_404 unless can?(current_user, :read_merge_request, @issuable) + + @issuable end def merge_request_includes(association) diff --git a/app/controllers/projects/merge_requests/diffs_controller.rb b/app/controllers/projects/merge_requests/diffs_controller.rb index 83377f67723..1c546d70df9 100644 --- a/app/controllers/projects/merge_requests/diffs_controller.rb +++ b/app/controllers/projects/merge_requests/diffs_controller.rb @@ -36,15 +36,17 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic diff_options_hash[:paths] = params[:paths] if params[:paths] diffs = @compare.diffs_in_batch(params[:page], params[:per_page], diff_options: diff_options_hash) - unfoldable_positions = @merge_request.note_positions_for_paths(diffs.diff_file_paths, current_user).unfoldable + + unfoldable_positions = Gitlab::Metrics.measure(:diffs_unfoldable_positions) do + @merge_request.note_positions_for_paths(diffs.diff_file_paths, current_user).unfoldable + end options = { merge_request: @merge_request, commit: commit, diff_view: diff_view, merge_ref_head_diff: render_merge_ref_head_diff?, - pagination_data: diffs.pagination_data, - merge_conflicts_in_diff: display_merge_conflicts_in_diff? + pagination_data: diffs.pagination_data } # NOTE: Any variables that would affect the resulting json needs to be added to the cache_context to avoid stale cache issues. @@ -56,16 +58,22 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic params[:expanded], params[:page], params[:per_page], - options[:merge_ref_head_diff], - options[:merge_conflicts_in_diff] + options[:merge_ref_head_diff] ] return unless stale?(etag: [cache_context + diff_options_hash.fetch(:paths, []), diffs]) - diffs.unfold_diff_files(unfoldable_positions) - diffs.write_cache + Gitlab::Metrics.measure(:diffs_unfold) do + diffs.unfold_diff_files(unfoldable_positions) + end + + Gitlab::Metrics.measure(:diffs_write_cache) do + diffs.write_cache + end - render json: PaginatedDiffSerializer.new(current_user: current_user).represent(diffs, options) + Gitlab::Metrics.measure(:diffs_render) do + render json: PaginatedDiffSerializer.new(current_user: current_user).represent(diffs, options) + end end # rubocop: enable Metrics/AbcSize @@ -74,8 +82,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic options = additional_attributes.merge( only_context_commits: show_only_context_commits?, - merge_ref_head_diff: render_merge_ref_head_diff?, - merge_conflicts_in_diff: display_merge_conflicts_in_diff? + merge_ref_head_diff: render_merge_ref_head_diff? ) render json: DiffsMetadataSerializer.new(project: @merge_request.project, current_user: current_user) @@ -103,8 +110,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic options = additional_attributes.merge( diff_view: "inline", - merge_ref_head_diff: render_merge_ref_head_diff?, - merge_conflicts_in_diff: display_merge_conflicts_in_diff? + merge_ref_head_diff: render_merge_ref_head_diff? ) options[:context_commits] = @merge_request.recent_context_commits @@ -232,8 +238,4 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter .track_mr_diffs_single_file_action(merge_request: @merge_request, user: current_user) end - - def display_merge_conflicts_in_diff? - Feature.enabled?(:display_merge_conflicts_in_diff, @merge_request.project) - end end |