1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-02 07:38:35 +00:00

Fix incorrect file links (#34189)

Fix #34188

The name "FileName" is ambiguous: sometimes it is "base name without
path", sometimes it is "full name with path".

The ambiguous name causes various problems.

This PR clarifies the usage: `FileTreePath`: the full name with path.
This commit is contained in:
wxiaoguang
2025-04-14 03:27:31 +08:00
committed by GitHub
parent a2651c14ce
commit 34349c085c
9 changed files with 17 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
<div {{if .ReadmeInList}}id="readme" {{end}}class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content">
<div {{if .ReadmeInList}}id="readme" {{end}}class="{{TabSizeClass .Editorconfig .FileTreePath}} non-diff-file-content">
{{- if .FileError}}
<div class="ui error message">
<div class="text left tw-whitespace-pre">{{.FileError}}</div>
@@ -27,7 +27,7 @@
<div class="file-header-left tw-flex tw-items-center tw-py-2 tw-pr-4">
{{if .ReadmeInList}}
{{svg "octicon-book" 16 "tw-mr-2"}}
<strong><a class="muted" href="#readme">{{.FileName}}</a></strong>
<strong><a class="muted" href="#readme">{{.FileTreePath}}</a></strong>
{{else}}
{{template "repo/file_info" .}}
{{end}}
@@ -78,7 +78,7 @@
<button class="ui mini basic button escape-button tw-mr-1">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button>
{{end}}
{{if and .ReadmeInList .CanEditReadmeFile}}
<a class="btn-octicon" data-tooltip-content="{{ctx.Locale.Tr "repo.editor.edit_this_file"}}" href="{{.RepoLink}}/_edit/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}/{{PathEscapeSegments .FileName}}">{{svg "octicon-pencil"}}</a>
<a class="btn-octicon" data-tooltip-content="{{ctx.Locale.Tr "repo.editor.edit_this_file"}}" href="{{.RepoLink}}/_edit/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .FileTreePath}}">{{svg "octicon-pencil"}}</a>
{{end}}
</div>
</h4>