summaryrefslogtreecommitdiff
path: root/app/views/projects/diffs/_file.html.haml
blob: c415ae2ddc8fa798700365edecc5d93116613218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
- blob = project.repository.blob_for_diff(@commit, diff_file.diff)
- return unless blob
- blob_diff_path = diff_project_blob_path(project, tree_join(@commit.id, diff_file.file_path))
.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
      %span= diff_file.old_path

      .diff-btn-group
        - if @commit.parent_ids.present?
          = view_file_btn(@commit.parent_id, diff_file, project)
    - else
      %span= diff_file.new_path
      - if diff_file.mode_changed?
        %span.file-mode= "#{diff_file.diff.a_mode} → #{diff_file.diff.b_mode}"

      .diff-btn-group
        - if blob.text?
          - unless params[:view] == 'parallel'
            %label
              = check_box_tag nil, 1, false, class: 'js-toggle-diff-line-wrap'
              Wrap text
           
          = link_to '#', class: 'js-toggle-diff-comments btn btn-small' do
            %i.fa.fa-chevron-down
            Diff comments
           

        - if @merge_request && @merge_request.source_project
          = link_to project_edit_tree_path(@merge_request.source_project, tree_join(@merge_request.source_branch, diff_file.new_path), from_merge_request_id: @merge_request.id), { class: 'btn btn-small' } do
            Edit
           

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

  .diff-content
    -# 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)
      = 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