forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
1{{ define "repo/fragments/interdiff" }} 2{{ $repo := index . 0 }} 3{{ $x := index . 1 }} 4{{ $opts := index . 2 }} 5{{ $fileTree := fileTree $x.AffectedFiles }} 6{{ $diff := $x.Files }} 7{{ $last := sub (len $diff) 1 }} 8{{ $isSplit := $opts.Split }} 9 10<div class="flex flex-col gap-4"> 11 {{ range $idx, $hunk := $diff }} 12 {{ with $hunk }} 13 <section class="border border-gray-200 dark:border-gray-700 w-full mx-auto rounded bg-white dark:bg-gray-800 drop-shadow-sm"> 14 <div id="file-{{ .Name }}"> 15 <div id="diff-file"> 16 <details {{ if not (.Status.IsOnlyInOne) }}open{{end}}> 17 <summary class="list-none cursor-pointer sticky top-0"> 18 <div id="diff-file-header" class="rounded cursor-pointer bg-white dark:bg-gray-800 flex justify-between"> 19 <div id="left-side-items" class="p-2 flex gap-2 items-center overflow-x-auto"> 20 <div class="flex gap-1 items-center" style="direction: ltr;"> 21 {{ $markerstyle := "diff-type p-1 mr-1 font-mono text-sm rounded select-none" }} 22 {{ if .Status.IsOk }} 23 <span class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}">CHANGED</span> 24 {{ else if .Status.IsUnchanged }} 25 <span class="bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}">UNCHANGED</span> 26 {{ else if .Status.IsOnlyInOne }} 27 <span class="bg-red-100 text-red-700 dark:bg-red-800/50 dark:text-red-400 {{ $markerstyle }}">REVERTED</span> 28 {{ else if .Status.IsOnlyInTwo }} 29 <span class="bg-green-100 text-green-700 dark:bg-green-800/50 dark:text-green-400 {{ $markerstyle }}">NEW</span> 30 {{ else if .Status.IsRebased }} 31 <span class="bg-amber-100 text-amber-700 dark:bg-amber-800/50 dark:text-amber-400 {{ $markerstyle }}">REBASED</span> 32 {{ else }} 33 <span class="bg-red-100 text-red-700 dark:bg-red-800/50 dark:text-red-400 {{ $markerstyle }}">ERROR</span> 34 {{ end }} 35 </div> 36 37 <div class="flex gap-2 items-center overflow-x-auto" style="direction: rtl;"> 38 <a class="dark:text-white whitespace-nowrap overflow-x-auto" href=""> 39 {{ .Name }} 40 </a> 41 </div> 42 </div> 43 44 {{ $iconstyle := "p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" }} 45 <div id="right-side-items" class="p-2 flex items-center"> 46 <a title="top of file" href="#file-{{ .Name }}" class="{{ $iconstyle }}">{{ i "arrow-up-to-line" "w-4 h-4" }}</a> 47 {{ if gt $idx 0 }} 48 {{ $prev := index $diff (sub $idx 1) }} 49 <a title="previous file" href="#file-{{ $prev.Name }}" class="{{ $iconstyle }}">{{ i "arrow-up" "w-4 h-4" }}</a> 50 {{ end }} 51 52 {{ if lt $idx $last }} 53 {{ $next := index $diff (add $idx 1) }} 54 <a title="next file" href="#file-{{ $next.Name }}" class="{{ $iconstyle }}">{{ i "arrow-down" "w-4 h-4" }}</a> 55 {{ end }} 56 </div> 57 58 </div> 59 </summary> 60 61 <div class="transition-all duration-700 ease-in-out"> 62 {{ if .Status.IsUnchanged }} 63 <p class="text-center text-gray-400 dark:text-gray-500 p-4"> 64 This file has not been changed. 65 </p> 66 {{ else if .Status.IsRebased }} 67 <p class="text-center text-gray-400 dark:text-gray-500 p-4"> 68 This patch was likely rebased, as context lines do not match. 69 </p> 70 {{ else if .Status.IsError }} 71 <p class="text-center text-gray-400 dark:text-gray-500 p-4"> 72 Failed to calculate interdiff for this file. 73 </p> 74 {{ else }} 75 {{ if $isSplit }} 76 {{- template "repo/fragments/splitDiff" .Split -}} 77 {{ else }} 78 {{- template "repo/fragments/unifiedDiff" . -}} 79 {{ end }} 80 {{- end -}} 81 </div> 82 83 </details> 84 85 </div> 86 </div> 87 </section> 88 {{ end }} 89 {{ end }} 90</div> 91{{ end }} 92