mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-18 00:56:41 +10:00
Correctly find last known blob for file deleted in MR. Fixes #3092. When building a new MR, `@merge_request.commits.last` would fail because this delegates to `merge_request_diff` which is still `nil` at that point. I fixed that, and changed some of the logic because showing deleted blob contents didn't previously work for the Compare page, and the UI would show the wrong commit sha for "View File @...". See merge request !1647
46 lines
1.9 KiB
Plaintext
46 lines
1.9 KiB
Plaintext
.diff-file{id: "diff-#{i}", data: diff_file_html_data(project, diff_commit, diff_file)}
|
|
.diff-header{id: "file-path-#{hexdigest(diff_file.file_path)}"}
|
|
- if diff_file.diff.submodule?
|
|
%span
|
|
- submodule_item = project.repository.blob_at(@commit.id, diff_file.file_path)
|
|
= submodule_link(submodule_item, @commit.id, project.repository)
|
|
- else
|
|
%span
|
|
- if diff_file.deleted_file
|
|
= "#{diff_file.old_path} deleted"
|
|
- elsif diff_file.renamed_file
|
|
= "#{diff_file.old_path} renamed to #{diff_file.new_path}"
|
|
- else
|
|
= diff_file.new_path
|
|
|
|
- if diff_file.mode_changed?
|
|
%span.file-mode= "#{diff_file.diff.a_mode} → #{diff_file.diff.b_mode}"
|
|
|
|
.diff-controls
|
|
- if blob.text?
|
|
= link_to '#', class: 'js-toggle-diff-comments btn btn-sm active has_tooltip', title: "Toggle comments for this file" do
|
|
%i.fa.fa-comments
|
|
|
|
|
|
- if editable_diff?(diff_file)
|
|
= edit_blob_link(@merge_request.source_project,
|
|
@merge_request.source_branch, diff_file.new_path,
|
|
after: ' ', from_merge_request_id: @merge_request.id)
|
|
|
|
= view_file_btn(diff_commit.id, diff_file, project)
|
|
|
|
.diff-content.diff-wrap-lines
|
|
-# Skipp all non non-supported blobs
|
|
- return unless blob.respond_to?('text?')
|
|
- if blob.text?
|
|
- if params[:view] == 'parallel'
|
|
= render "projects/diffs/parallel_view", diff_file: diff_file, project: project, blob: blob, index: i
|
|
- else
|
|
= render "projects/diffs/text_file", diff_file: diff_file, index: i
|
|
- elsif blob.image?
|
|
- old_file = project.repository.prev_blob_for_diff(diff_commit, diff_file)
|
|
= render "projects/diffs/image", diff_file: diff_file, old_file: old_file, file: blob, index: i
|
|
- else
|
|
.nothing-here-block No preview for this file type
|
|
|