{{ define "fragments/diff" }} {{ $repo := index . 0 }} {{ $diff := index . 1 }} {{ $commit := $diff.Commit }} {{ $stat := $diff.Stat }} {{ $diff := $diff.Diff }} {{ $this := $commit.This }} {{ $parent := $commit.Parent }} {{ $last := sub (len $diff) 1 }} {{ range $idx, $hunk := $diff }} {{ with $hunk }}
{{ $markerstyle := "diff-type p-1 mr-1 font-mono text-sm rounded select-none" }} {{ if .IsNew }} ADDED {{ else if .IsDelete }} DELETED {{ else if .IsCopy }} COPIED {{ else if .IsRename }} RENAMED {{ else }} MODIFIED {{ end }} {{ if .IsDelete }} {{ .Name.Old }} {{ else if (or .IsCopy .IsRename) }} {{ .Name.Old }} {{ .Name.New }} {{ else }} {{ .Name.New }} {{ end }}
{{ $iconstyle := "p-1 mx-1 hover:bg-gray-100 rounded" }}
{{ if gt $idx 0 }} {{ $prev := index $diff (sub $idx 1) }} {{ end }} {{ if lt $idx $last }} {{ $next := index $diff (add $idx 1) }} {{ end }}
{{ if .IsDelete }}

This file has been deleted in this commit.

{{ else }} {{ if .IsBinary }}

This is a binary file and will not be displayed.

{{ else }}
              {{- range .TextFragments -}}
                
{{ .Header }}
{{- range .Lines -}} {{- if eq .Op.String "+" -}}
{{ .Op.String }}{{ .Line }}
{{- end -}} {{- if eq .Op.String "-" -}}
{{ .Op.String }}{{ .Line }}
{{- end -}} {{- if eq .Op.String " " -}}
{{ .Op.String }}{{ .Line }}
{{- end -}} {{- end -}} {{- end -}}
{{- end -}} {{ end }}
{{ end }} {{ end }} {{ end }}