From 62fbca3af4cfaedc796e23ddb3544c7aaf846184 Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 8 Apr 2021 20:35:47 +0100 Subject: [PATCH] Show diff on rename with diff changes (#15338) (#15340) Backport #15338 More recent versions of git have increased support for detection of renames meaning that a rename with diff changes is now supported. Although ParsePatch supports this - our templates do not and the simplest solution is simply to show the diff. Fix #15335 Signed-off-by: Andrew Thornton Co-authored-by: 6543 <6543@obermui.de> --- templates/repo/diff/box.tmpl | 268 +++++++++++++++++------------------ 1 file changed, 132 insertions(+), 136 deletions(-) diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index f6e49126bf..61b2788999 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -57,14 +57,12 @@

- {{if not $file.IsRenamed}} - + {{.Addition}} - -
-
-
- - {{.Deletion}} - {{end}} + + {{.Addition}} + +
+
+
+ - {{.Deletion}}
{{$file.Name}}
{{$.i18n.Tr "repo.diff.file_suppressed"}}
@@ -97,7 +95,7 @@
{{if $file.IsBin}} {{$.i18n.Tr "repo.diff.bin"}} - {{else if not $file.IsRenamed}} + {{else}} + {{.Addition}}
@@ -119,138 +117,136 @@ {{end}}

- {{if ne $file.Type 4}} -
- - - {{if $isImage}} - {{template "repo/diff/image_diff" dict "file" . "root" $}} - {{else}} - {{if $.IsSplitStyle}} - {{range $j, $section := $file.Sections}} - {{range $k, $line := $section.Lines}} - - {{if eq .GetType 4}} - - - {{else}} - - - - - - - {{end}} - - {{if gt (len $line.Comments) 0}} - {{$resolved := (index $line.Comments 0).IsResolved}} - {{$resolveDoer := (index $line.Comments 0).ResolveDoer}} - {{$isNotPending := (not (eq (index $line.Comments 0).Review.Type 0))}} - - - - - - - - +
+
- {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }} - - {{svg "octicon-fold-down"}} - - {{end}} - {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }} - - {{svg "octicon-fold-up"}} - - {{end}} - {{if eq $line.GetExpandDirection 2}} - - {{svg "octicon-fold"}} - - {{end}} - {{$section.GetComputedInlineDiffFor $line}}{{if $line.LeftIdx}}{{end}}{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}{{end}}{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}{{if $line.RightIdx}}{{end}}{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}{{end}}{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
-
- {{if and $resolved (eq $line.GetCommentSide "previous")}} -
- {{$resolveDoer.Name}} {{$.i18n.Tr "repo.issues.review.resolved_by"}} - - -
- {{end}} - {{if eq $line.GetCommentSide "previous"}} -
-
- - {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}} - -
- {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}} - {{if and $.CanMarkConversation $isNotPending}} - - {{end}} -
- {{end}} -
-
-
- {{if and $resolved (eq $line.GetCommentSide "proposed")}} -
- {{$resolveDoer.Name}} {{$.i18n.Tr "repo.issues.review.resolved_by"}} - - -
- {{end}} - {{if eq $line.GetCommentSide "proposed"}} -
-
- - {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}} - -
- {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}} - {{if and $.CanMarkConversation $isNotPending}} - - {{end}} -
- {{end}} -
-
+ + {{if $isImage}} + {{template "repo/diff/image_diff" dict "file" . "root" $}} + {{else}} + {{if $.IsSplitStyle}} + {{range $j, $section := $file.Sections}} + {{range $k, $line := $section.Lines}} + + {{if eq .GetType 4}} + + + {{else}} + + + + + + {{end}} + + {{if gt (len $line.Comments) 0}} + {{$resolved := (index $line.Comments 0).IsResolved}} + {{$resolveDoer := (index $line.Comments 0).ResolveDoer}} + {{$isNotPending := (not (eq (index $line.Comments 0).Review.Type 0))}} + + + + + + + + {{end}} {{end}} - {{else}} - {{template "repo/diff/section_unified" dict "file" . "root" $}} {{end}} + {{else}} + {{template "repo/diff/section_unified" dict "file" . "root" $}} {{end}} - -
+ {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }} + + {{svg "octicon-fold-down"}} + + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }} + + {{svg "octicon-fold-up"}} + + {{end}} + {{if eq $line.GetExpandDirection 2}} + + {{svg "octicon-fold"}} + + {{end}} + {{$section.GetComputedInlineDiffFor $line}}{{if $line.LeftIdx}}{{end}}{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}{{end}}{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}{{if $line.RightIdx}}{{end}}{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}{{end}}{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
+
+ {{if and $resolved (eq $line.GetCommentSide "previous")}} +
+ {{$resolveDoer.Name}} {{$.i18n.Tr "repo.issues.review.resolved_by"}} + + +
+ {{end}} + {{if eq $line.GetCommentSide "previous"}} +
+
+ + {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}} + +
+ {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}} + {{if and $.CanMarkConversation $isNotPending}} + + {{end}} +
+ {{end}} +
+
+
+ {{if and $resolved (eq $line.GetCommentSide "proposed")}} +
+ {{$resolveDoer.Name}} {{$.i18n.Tr "repo.issues.review.resolved_by"}} + + +
+ {{end}} + {{if eq $line.GetCommentSide "proposed"}} +
+
+ + {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}} + +
+ {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}} + {{if and $.CanMarkConversation $isNotPending}} + + {{end}} +
+ {{end}} +
+
-
- {{end}} + {{end}} + + +
{{end}}