aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo
diff options
context:
space:
mode:
authoroliverpool <3864879+oliverpool@users.noreply.github.com>2023-05-10 05:43:55 +0200
committerGitHub <noreply@github.com>2023-05-10 11:43:55 +0800
commit8030614386b5d3fa02dc294446a344d274b04a26 (patch)
tree33868012ca12609feafbb3e938e0fcb5efeb5130 /templates/repo
parent5930ab5fdf7a970fcca3cd50b44cf1cacb615a54 (diff)
downloadgitea-8030614386b5d3fa02dc294446a344d274b04a26.tar.gz
gitea-8030614386b5d3fa02dc294446a344d274b04a26.zip
fix: release page for empty or non-existing target (#24470)
Fixes #24145 To solve the bug, I added a "computed" `TargetBehind` field to the `Release` model, which indicates the target branch of a release. This is particularly useful if the target branch was deleted in the meantime (or is empty). I also did a micro-optimization in `calReleaseNumCommitsBehind`. Instead of checking that a branch exists and then call `GetBranchCommit`, I immediately call `GetBranchCommit` and handle the `git.ErrNotExist` error. This optimization is covered by the added unit test.
Diffstat (limited to 'templates/repo')
-rw-r--r--templates/repo/release/list.tmpl4
1 files changed, 2 insertions, 2 deletions
diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl
index be0976c1af..2dcb012412 100644
--- a/templates/repo/release/list.tmpl
+++ b/templates/repo/release/list.tmpl
@@ -56,7 +56,7 @@
{{end}}
|
{{end}}
- <span class="ahead"><a href="{{$.RepoLink}}/compare/{{.TagName | PathEscapeSegments}}{{if .Target}}...{{.Target | PathEscapeSegments}}{{end}}">{{$.locale.Tr "repo.release.ahead.commits" .NumCommitsBehind | Str2html}}</a> {{$.locale.Tr "repo.tag.ahead.target" $.DefaultBranch}}</span>
+ <span class="ahead"><a href="{{$.RepoLink}}/compare/{{.TagName | PathEscapeSegments}}...{{.TargetBehind | PathEscapeSegments}}">{{$.locale.Tr "repo.release.ahead.commits" .NumCommitsBehind | Str2html}}</a> {{$.locale.Tr "repo.tag.ahead.target" .TargetBehind}}</span>
</p>
{{else}}
<p class="text grey">
@@ -77,7 +77,7 @@
<span class="time">{{TimeSinceUnix .CreatedUnix $.locale}}</span>
{{end}}
{{if not .IsDraft}}
- | <span class="ahead"><a href="{{$.RepoLink}}/compare/{{.TagName | PathEscapeSegments}}...{{.Target | PathEscapeSegments}}">{{$.locale.Tr "repo.release.ahead.commits" .NumCommitsBehind | Str2html}}</a> {{$.locale.Tr "repo.release.ahead.target" .Target}}</span>
+ | <span class="ahead"><a href="{{$.RepoLink}}/compare/{{.TagName | PathEscapeSegments}}...{{.TargetBehind | PathEscapeSegments}}">{{$.locale.Tr "repo.release.ahead.commits" .NumCommitsBehind | Str2html}}</a> {{$.locale.Tr "repo.release.ahead.target" .TargetBehind}}</span>
{{end}}
</p>
{{end}}