aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-04-29 12:26:52 +0200
committerGitHub <noreply@github.com>2022-04-29 12:26:52 +0200
commite5c6c001c5f5299a63b4ccbd7aaeea486d6b5c53 (patch)
tree086e502b2c1b2665128ebea48334daede7d4c0f2
parent3e2bba08035136a43786db47ba69a37d19b06304 (diff)
downloadgitea-e5c6c001c5f5299a63b4ccbd7aaeea486d6b5c53.tar.gz
gitea-e5c6c001c5f5299a63b4ccbd7aaeea486d6b5c53.zip
Permalink files In PR diff (#19534)
-rw-r--r--templates/repo/diff/box.tmpl7
1 files changed, 4 insertions, 3 deletions
diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl
index b7135de59f..c3af6bbd11 100644
--- a/templates/repo/diff/box.tmpl
+++ b/templates/repo/diff/box.tmpl
@@ -39,7 +39,7 @@
</div>
<!-- todo finish all file status, now modify, add, delete and rename -->
<span class="status {{DiffTypeToStr .GetType}} tooltip" data-content="{{DiffTypeToStr .GetType}}" data-position="right center">&nbsp;</span>
- <a class="file mono" href="#diff-{{.Index}}">{{.Name}}</a>
+ <a class="file mono" href="#diff-{{Sha1 .Name}}">{{.Name}}</a>
</li>
{{end}}
{{if .Diff.IsIncomplete}}
@@ -57,7 +57,8 @@
{{$isImage := or (call $.IsBlobAnImage $blobBase) (call $.IsBlobAnImage $blobHead)}}
{{$isCsv := (call $.IsCsvFile $file)}}
{{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv)}}
- <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}} mt-3" id="diff-{{.Index}}" data-old-filename="{{$file.OldName}}" data-new-filename="{{$file.Name}}" {{if $file.IsGenerated}}data-folded="true"{{end}}>
+ {{$nameHash := Sha1 $file.Name}}
+ <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}} mt-3" id="diff-{{$nameHash}}" data-old-filename="{{$file.OldName}}" data-new-filename="{{$file.Name}}" {{if $file.IsGenerated}}data-folded="true"{{end}}>
<h4 class="diff-file-header sticky-2nd-row ui top attached normal header df ac sb">
<div class="df ac">
<a role="button" class="fold-file muted mr-2">
@@ -76,7 +77,7 @@
{{template "repo/diff/stats" dict "file" . "root" $}}
{{end}}
</div>
- <span class="file mono">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
+ <span class="file mono"><a href="#diff-{{$nameHash}}">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}</a>{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
{{if $file.IsGenerated}}
<span class="ui label ml-3">{{$.i18n.Tr "repo.diff.generated"}}</span>
{{end}}