Skip to content

Commit a0ccd6b

Browse files
KN4CK3RAbdulrhmnGhanem
authored andcommitted
Permalink files In PR diff (go-gitea#19534)
1 parent e4e84fa commit a0ccd6b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

templates/repo/diff/box.tmpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</div>
4040
<!-- todo finish all file status, now modify, add, delete and rename -->
4141
<span class="status {{DiffTypeToStr .GetType}} tooltip" data-content="{{DiffTypeToStr .GetType}}" data-position="right center">&nbsp;</span>
42-
<a class="file mono" href="#diff-{{.Index}}">{{.Name}}</a>
42+
<a class="file mono" href="#diff-{{Sha1 .Name}}">{{.Name}}</a>
4343
</li>
4444
{{end}}
4545
{{if .Diff.IsIncomplete}}
@@ -57,7 +57,8 @@
5757
{{$isImage := or (call $.IsBlobAnImage $blobBase) (call $.IsBlobAnImage $blobHead)}}
5858
{{$isCsv := (call $.IsCsvFile $file)}}
5959
{{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv)}}
60-
<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}}>
60+
{{$nameHash := Sha1 $file.Name}}
61+
<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}}>
6162
<h4 class="diff-file-header sticky-2nd-row ui top attached normal header df ac sb">
6263
<div class="df ac">
6364
<a role="button" class="fold-file muted mr-2">
@@ -76,7 +77,7 @@
7677
{{template "repo/diff/stats" dict "file" . "root" $}}
7778
{{end}}
7879
</div>
79-
<span class="file mono">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
80+
<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>
8081
{{if $file.IsGenerated}}
8182
<span class="ui label ml-3">{{$.i18n.Tr "repo.diff.generated"}}</span>
8283
{{end}}

0 commit comments

Comments
 (0)