From 72111e698ea95abef06bf915cf850b0e75867a1a Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Tue, 31 Mar 2020 04:50:59 +0800 Subject: template: better diff handling of rename and deleted files (#6048) * dep: bump github.com/gogs/git-module from 1.0.2 to 1.1.0 * template: better diff handling or rename and deleted files --- templates/repo/diff/box.tmpl | 102 +++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 48 deletions(-) (limited to 'templates/repo/diff') diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 297c84f1..1980d774 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -39,14 +39,12 @@

{{$.i18n.Tr "repo.diff.file_suppressed"}}
- {{if not $file.IsRenamed}} - + {{.NumAdditions}} - - - - - - {{.NumDeletions}} - {{end}} + + {{.NumAdditions}} + + + + + - {{.NumDeletions}}
{{$file.Name}}

@@ -57,7 +55,7 @@
{{if $file.IsBinary}} {{$.i18n.Tr "repo.diff.bin"}} - {{else if not $file.IsRenamed}} + {{else}} + {{.NumAdditions}} @@ -78,48 +76,56 @@ {{end}}
- {{if not $file.IsRenamed}} - {{$isImage := (call $.IsImageFile $file.Name)}} - {{if $isImage}} -
+ {{$isImage := false}} + {{if $file.IsDeleted}} + {{$isImage = (call $.IsImageFileByIndex $file.Index)}} + {{else}} + {{$isImage = (call $.IsImageFile $file.Name)}} + {{end}} + + {{if $isImage}} +
+ {{if $file.IsDeleted}} + + {{else}} -
- {{else}} -
- - - {{if $.IsSplitStyle}} - {{$highlightClass := $file.HighlightClass}} - {{range $j, $section := $file.Sections}} - {{range $k, $line := $section.Lines}} - - {{if eq .Type 4}} - - - {{else}} - - - - - {{end}} - - {{end}} + {{end}} + + {{else}} +
+
-
{{$section.ComputedInlineDiffFor $line}}
-
- -
{{if $line.LeftLine}}{{$section.ComputedInlineDiffFor $line}}{{end}}
-
- -
{{if $line.RightLine}}{{$section.ComputedInlineDiffFor $line}}{{end}}
-
+ + {{if $.IsSplitStyle}} + {{$highlightClass := $file.HighlightClass}} + {{range $j, $section := $file.Sections}} + {{range $k, $line := $section.Lines}} + + {{if eq .Type 4}} + + + {{else}} + + + + + {{end}} + {{end}} - {{else}} - {{template "repo/diff/section_unified" .}} {{end}} - -
+
{{$section.ComputedInlineDiffFor $line}}
+
+ +
{{if $line.LeftLine}}{{$section.ComputedInlineDiffFor $line}}{{end}}
+
+ +
{{if $line.RightLine}}{{$section.ComputedInlineDiffFor $line}}{{end}}
+
-
- {{end}} + {{else}} + {{template "repo/diff/section_unified" .}} + {{end}} + + +
{{end}}
-- cgit v1.2.3