_file.html.haml 2.14 KB
Newer Older
1 2
- blob = project.repository.blob_for_diff(@commit, diff_file.diff)
- return unless blob
Vinnie Okada's avatar
Vinnie Okada committed
3
- blob_diff_path = namespace_project_blob_diff_path(project.namespace, project, tree_join(@commit.id, diff_file.file_path))
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
4 5 6
.diff-file{id: "diff-#{i}", data: {blob_diff_path: blob_diff_path }}
  .diff-header{id: "file-path-#{hexdigest(diff_file.new_path || diff_file.old_path)}"}
    - if diff_file.deleted_file
7
      %span="#{diff_file.old_path} deleted"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
8 9 10 11

      .diff-btn-group
        - if @commit.parent_ids.present?
          = view_file_btn(@commit.parent_id, diff_file, project)
Headless's avatar
Headless committed
12 13 14
    - elsif diff_file.diff.submodule?
      - submodule_item = project.repository.blob_at(@commit.id, diff_file.file_path)
      = submodule_link(submodule_item, @commit.id)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
15
    - else
16 17 18 19
      - if diff_file.renamed_file
        %span= "#{diff_file.old_path} renamed to #{diff_file.new_path}"
      - else
        %span= diff_file.new_path
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
20
      - if diff_file.mode_changed?
21
        %span.file-mode= "#{diff_file.diff.a_mode}#{diff_file.diff.b_mode}"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
22 23

      .diff-btn-group
24
        - if blob.text?
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
25
          = link_to '#', class: 'js-toggle-diff-comments btn btn-sm' do
26
            %i.fa.fa-chevron-down
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
27
            Show/Hide comments
28
           
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
29 30

        - if @merge_request && @merge_request.source_project
31 32 33
          = edit_blob_link(@merge_request.source_project,
              @merge_request.source_branch, diff_file.new_path,
              after: ' ', from_merge_request_id: @merge_request.id)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
34 35 36

        = view_file_btn(@commit.id, diff_file, project)

37
  .diff-content.diff-wrap-lines
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
38 39 40 41 42 43 44 45 46
    -# 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(@commit, diff_file)
47
      = render "projects/diffs/image", diff_file: diff_file, old_file: old_file, file: blob, index: i
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
48 49 50
    - else
      .nothing-here-block No preview for this file type