forgejo/routers
oliverpool 937b8e8184
fix: release page for empty or non-existing target (#24659)
Backport #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.

_contributed in the context of @forgejo_

(cherry picked from commit cb7ba8969d)
2023-05-16 07:42:22 +02:00
..
api [BRANDING] X-Forgejo-OTP can be used instead of X-Gitea-OTP 2023-05-10 11:05:22 +02:00
common Support sanitising the URL by removing extra slashes in the URL (#21333) (#23300) 2023-03-05 02:14:12 -05:00
install [BRANDING] Rebrand default config settings for new installs (#140) 2023-05-10 11:05:21 +02:00
private Refactor the setting to make unit test easier (#22405) 2023-02-20 00:12:01 +08:00
utils Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
web fix: release page for empty or non-existing target (#24659) 2023-05-16 07:42:22 +02:00
init.go [API] Forgejo API /api/forgejo/v1 2023-05-10 09:20:14 +02:00