diff options
Diffstat (limited to 'app/controllers/projects/merge_requests/diffs_controller.rb')
-rw-r--r-- | app/controllers/projects/merge_requests/diffs_controller.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/app/controllers/projects/merge_requests/diffs_controller.rb b/app/controllers/projects/merge_requests/diffs_controller.rb index 418e7233e21..c88dbc70ed5 100644 --- a/app/controllers/projects/merge_requests/diffs_controller.rb +++ b/app/controllers/projects/merge_requests/diffs_controller.rb @@ -38,16 +38,13 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic 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 - diffs.unfold_diff_files(unfoldable_positions) - diffs.write_cache - 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, - allow_tree_conflicts: display_merge_conflicts_in_diff? + merge_conflicts_in_diff: display_merge_conflicts_in_diff? } # NOTE: Any variables that would affect the resulting json needs to be added to the cache_context to avoid stale cache issues. @@ -60,10 +57,19 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic params[:page], params[:per_page], options[:merge_ref_head_diff], - options[:allow_tree_conflicts] + options[:merge_conflicts_in_diff] ] - return unless stale?(etag: [cache_context + diff_options_hash.fetch(:paths, []), diffs]) + if Feature.enabled?(:check_etags_diffs_batch_before_write_cache, merge_request.project) && !stale?(etag: [cache_context + diff_options_hash.fetch(:paths, []), diffs]) + return + end + + diffs.unfold_diff_files(unfoldable_positions) + diffs.write_cache + + if Feature.disabled?(:check_etags_diffs_batch_before_write_cache, merge_request.project) && !stale?(etag: [cache_context + diff_options_hash.fetch(:paths, []), diffs]) + return + end render json: PaginatedDiffSerializer.new(current_user: current_user).represent(diffs, options) end @@ -75,7 +81,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?, - allow_tree_conflicts: display_merge_conflicts_in_diff? + merge_conflicts_in_diff: display_merge_conflicts_in_diff? ) render json: DiffsMetadataSerializer.new(project: @merge_request.project, current_user: current_user) @@ -104,7 +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?, - allow_tree_conflicts: display_merge_conflicts_in_diff? + merge_conflicts_in_diff: display_merge_conflicts_in_diff? ) options[:context_commits] = @merge_request.recent_context_commits |