this repo has no description
1{{ define "repo/fragments/diff" }} 2 {{ $repo := index . 0 }} 3 {{ $diff := index . 1 }} 4 {{ $opts := index . 2 }} 5 6 {{ $commit := $diff.Commit }} 7 {{ $diff := $diff.Diff }} 8 {{ $isSplit := $opts.Split }} 9 {{ $this := $commit.This }} 10 {{ $parent := $commit.Parent }} 11 {{ $last := sub (len $diff) 1 }} 12 13 14 <div class="flex flex-col gap-4"> 15 {{ range $idx, $hunk := $diff }} 16 {{ with $hunk }} 17 <section 18 class="border border-gray-200 dark:border-gray-700 w-full mx-auto rounded bg-white dark:bg-gray-800 drop-shadow-sm"> 19 <div id="file-{{ .Name.New }}"> 20 <div id="diff-file"> 21 <details open> 22 <summary class="list-none cursor-pointer sticky top-0"> 23 <div 24 id="diff-file-header" 25 class="rounded cursor-pointer bg-white dark:bg-gray-800 flex justify-between"> 26 <div 27 id="left-side-items" 28 class="p-2 flex gap-2 items-center overflow-x-auto"> 29 <div class="flex gap-1 items-center"> 30 {{ $markerstyle := "diff-type p-1 mr-1 font-mono text-sm rounded select-none" }} 31 {{ if .IsNew }} 32 <span 33 class="bg-green-100 text-green-700 dark:bg-green-800/50 dark:text-green-400 {{ $markerstyle }}"> 34 ADDED 35 </span> 36 {{ else if .IsDelete }} 37 <span 38 class="bg-red-100 text-red-700 dark:bg-red-800/50 dark:text-red-400 {{ $markerstyle }}"> 39 DELETED 40 </span> 41 {{ else if .IsCopy }} 42 <span 43 class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}"> 44 COPIED 45 </span> 46 {{ else if .IsRename }} 47 <span 48 class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}"> 49 RENAMED 50 </span> 51 {{ else }} 52 <span 53 class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}"> 54 MODIFIED 55 </span> 56 {{ end }} 57 58 {{ template "repo/fragments/diffStatPill" .Stats }} 59 </div> 60 61 <div class="flex gap-2 items-center overflow-x-auto"> 62 {{ if .IsDelete }} 63 <a 64 class="dark:text-white whitespace-nowrap overflow-x-auto" 65 {{ if $this }} 66 href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.Old }}" 67 {{ end }}> 68 {{ .Name.Old }} 69 </a> 70 {{ else if (or .IsCopy .IsRename) }} 71 <a 72 class="dark:text-white whitespace-nowrap overflow-x-auto" 73 {{ if $parent }} 74 href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}" 75 {{ end }}> 76 {{ .Name.Old }} 77 </a> 78 {{ i "arrow-right" "w-4 h-4" }} 79 <a 80 class="dark:text-white whitespace-nowrap overflow-x-auto" 81 {{ if $this }} 82 href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}" 83 {{ end }}> 84 {{ .Name.New }} 85 </a> 86 {{ else }} 87 <a 88 class="dark:text-white whitespace-nowrap overflow-x-auto" 89 {{ if $this }} 90 href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}" 91 {{ end }}> 92 {{ .Name.New }} 93 </a> 94 {{ end }} 95 </div> 96 </div> 97 98 {{ $iconstyle := "p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" }} 99 <div id="right-side-items" class="p-2 flex items-center"> 100 <a 101 title="top of file" 102 href="#file-{{ .Name.New }}" 103 class="{{ $iconstyle }}"> 104 {{ i "arrow-up-to-line" "w-4 h-4" }} 105 </a> 106 {{ if gt $idx 0 }} 107 {{ $prev := index $diff (sub $idx 1) }} 108 <a 109 title="previous file" 110 href="#file-{{ $prev.Name.New }}" 111 class="{{ $iconstyle }}"> 112 {{ i "arrow-up" "w-4 h-4" }} 113 </a> 114 {{ end }} 115 116 {{ if lt $idx $last }} 117 {{ $next := index $diff (add $idx 1) }} 118 <a 119 title="next file" 120 href="#file-{{ $next.Name.New }}" 121 class="{{ $iconstyle }}"> 122 {{ i "arrow-down" "w-4 h-4" }} 123 </a> 124 {{ end }} 125 </div> 126 </div> 127 </summary> 128 129 <div class="transition-all duration-700 ease-in-out"> 130 {{ if .IsDelete }} 131 <p class="text-center text-gray-400 dark:text-gray-500 p-4"> 132 This file has been deleted. 133 </p> 134 {{ else if .IsCopy }} 135 <p class="text-center text-gray-400 dark:text-gray-500 p-4"> 136 This file has been copied. 137 </p> 138 {{ else if .IsBinary }} 139 <p class="text-center text-gray-400 dark:text-gray-500 p-4"> 140 This is a binary file and will not be displayed. 141 </p> 142 {{ else }} 143 {{ if $isSplit }} 144 {{- template "repo/fragments/splitDiff" .Split -}} 145 {{ else }} 146 {{- template "repo/fragments/unifiedDiff" . -}} 147 {{ end }} 148 {{- end -}} 149 </div> 150 </details> 151 </div> 152 </div> 153 </section> 154 {{ end }} 155 {{ end }} 156 </div> 157{{ end }}