]> source.dussan.org Git - gitea.git/commitdiff
Fix link to `Code` tab on wiki commits (#28041)
authorJakobDev <jakobdev@gmx.de>
Mon, 27 Nov 2023 05:59:56 +0000 (06:59 +0100)
committerGitHub <noreply@github.com>
Mon, 27 Nov 2023 05:59:56 +0000 (05:59 +0000)
Fixes https://codeberg.org/forgejo/forgejo/issues/1759

If you are bowing another branch than the default branch and click n the
Code tab, it will take you to the root of the branch. The `BranchName`
variable is also set when viewing a Wiki commit, so we also need to
check if we are on a Wiki.

templates/repo/header.tmpl

index 895d18d6fd84f14cf2f7418b3c6a91553b70a32b..f306435409e3f7e0e33c4ff2c03f5fdebdc246a4 100644 (file)
                {{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}}
                        <div class="ui tabular menu navbar gt-overflow-x-auto gt-overflow-y-hidden">
                                {{if .Permission.CanRead $.UnitTypeCode}}
-                               <a class="{{if .PageIsViewCode}}active {{end}}item" href="{{.RepoLink}}{{if (ne .BranchName .Repository.DefaultBranch)}}/src/{{.BranchNameSubURL}}{{end}}">
+                               <a class="{{if .PageIsViewCode}}active {{end}}item" href="{{.RepoLink}}{{if and (ne .BranchName .Repository.DefaultBranch) (not $.PageIsWiki)}}/src/{{.BranchNameSubURL}}{{end}}">
                                        {{svg "octicon-code"}} {{ctx.Locale.Tr "repo.code"}}
                                </a>
                                {{end}}