this repo has no description
1{{ define "fragments/diff" }}
2{{ $repo := index . 0 }}
3{{ $diff := index . 1 }}
4{{ $commit := $diff.Commit }}
5{{ $stat := $diff.Stat }}
6{{ $diff := $diff.Diff }}
7
8 {{ $this := $commit.This }}
9 {{ $parent := $commit.Parent }}
10
11 {{ $last := sub (len $diff) 1 }}
12 {{ range $idx, $hunk := $diff }}
13 {{ with $hunk }}
14 <section class="mt-6 border border-gray-200 dark:border-gray-700 w-full mx-auto rounded bg-white dark:bg-gray-800 drop-shadow-sm">
15 <div id="file-{{ .Name.New }}">
16 <div id="diff-file">
17 <details open>
18 <summary class="list-none cursor-pointer sticky top-0">
19 <div id="diff-file-header" class="rounded cursor-pointer bg-white dark:bg-gray-800 flex justify-between">
20 <div id="left-side-items" class="p-2 flex gap-2 items-center">
21 {{ $markerstyle := "diff-type p-1 mr-1 font-mono text-sm rounded select-none" }}
22
23 {{ if .IsNew }}
24 <span class="bg-green-100 text-green-700 dark:bg-green-800/50 dark:text-green-400 {{ $markerstyle }}">ADDED</span>
25 {{ else if .IsDelete }}
26 <span class="bg-red-100 text-red-700 dark:bg-red-800/50 dark:text-red-400 {{ $markerstyle }}">DELETED</span>
27 {{ else if .IsCopy }}
28 <span class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}">COPIED</span>
29 {{ else if .IsRename }}
30 <span class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}">RENAMED</span>
31 {{ else }}
32 <span class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}">MODIFIED</span>
33 {{ end }}
34
35 {{ if .IsDelete }}
36 <a class="dark:text-white" {{if $this }}href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.Old }}"{{end}}>
37 {{ .Name.Old }}
38 </a>
39 {{ else if (or .IsCopy .IsRename) }}
40 <a class="dark:text-white" {{if $parent}}href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}"{{end}}>
41 {{ .Name.Old }}
42 </a>
43 {{ i "arrow-right" "w-4 h-4" }}
44 <a class="dark:text-white" {{if $this}}href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}"{{end}}>
45 {{ .Name.New }}
46 </a>
47 {{ else }}
48 <a class="dark:text-white" {{if $this}}href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}"{{end}}>
49 {{ .Name.New }}
50 </a>
51 {{ end }}
52 </div>
53
54 {{ $iconstyle := "p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" }}
55 <div id="right-side-items" class="p-2 flex items-center">
56 <a title="top of file" href="#file-{{ .Name.New }}" class="{{ $iconstyle }}">{{ i "arrow-up-to-line" "w-4 h-4" }}</a>
57 {{ if gt $idx 0 }}
58 {{ $prev := index $diff (sub $idx 1) }}
59 <a title="previous file" href="#file-{{ $prev.Name.New }}" class="{{ $iconstyle }}">{{ i "arrow-up" "w-4 h-4" }}</a>
60 {{ end }}
61
62 {{ if lt $idx $last }}
63 {{ $next := index $diff (add $idx 1) }}
64 <a title="next file" href="#file-{{ $next.Name.New }}" class="{{ $iconstyle }}">{{ i "arrow-down" "w-4 h-4" }}</a>
65 {{ end }}
66 </div>
67
68 </div>
69 </summary>
70
71 <div class="transition-all duration-700 ease-in-out">
72 {{ if .IsDelete }}
73 <p class="text-center text-gray-400 dark:text-gray-500 p-4">
74 This file has been deleted in this commit.
75 </p>
76 {{ else }}
77 {{ if .IsBinary }}
78 <p class="text-center text-gray-400 dark:text-gray-500 p-4">
79 This is a binary file and will not be displayed.
80 </p>
81 {{ else }}
82 <pre class="overflow-x-auto">
83 {{- range .TextFragments -}}
84 <div class="bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 select-none">{{- .Header -}}</div><div class="overflow-x-auto"><div class="min-w-full inline-block">
85 {{- range .Lines -}}
86 {{- if eq .Op.String "+" -}}
87 <div class="bg-green-100 dark:bg-green-800/30 text-green-700 dark:text-green-400 flex min-w-full">
88 <div class="w-10 flex-shrink-0 select-none p-1 text-center">{{ .Op.String }}</div>
89 <div class="p-1 whitespace-pre">{{ .Line }}</div>
90 </div>
91 {{- end -}}
92 {{- if eq .Op.String "-" -}}
93 <div class="bg-red-100 dark:bg-red-800/30 text-red-700 dark:text-red-400 flex min-w-full">
94 <div class="w-10 flex-shrink-0 select-none p-1 text-center">{{ .Op.String }}</div>
95 <div class="p-1 whitespace-pre">{{ .Line }}</div>
96 </div>
97 {{- end -}}
98 {{- if eq .Op.String " " -}}
99 <div class="bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400 flex min-w-full">
100 <div class="w-10 flex-shrink-0 select-none p-1 text-center">{{ .Op.String }}</div>
101 <div class="p-1 whitespace-pre">{{ .Line }}</div>
102 </div>
103 {{- end -}}
104 {{- end -}}</div></div>{{- end -}}
105 </pre>
106 {{- end -}}
107 {{ end }}
108 </div>
109
110 </details>
111
112 </div>
113 </div>
114 </section>
115 {{ end }}
116 {{ end }}
117{{ end }}