Skip to content

'Commits since this release' link broken for API created releases #24145

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
oliverpool opened this issue Apr 15, 2023 · 2 comments · Fixed by #24470
Closed

'Commits since this release' link broken for API created releases #24145

oliverpool opened this issue Apr 15, 2023 · 2 comments · Fixed by #24470
Labels
Milestone

Comments

@oliverpool
Copy link
Contributor

oliverpool commented Apr 15, 2023

Description

When a release is created via the API with an empty target, the release page is a bit broken: https://codeberg.org/forgejo-contrib/forgejo-helm/releases/tag/v0.6.1

13 commits to since this release

The branch bame name is missing between "to" and "since" and the 0 commits link points to a 404 (eg https://codeberg.org/forgejo-contrib/forgejo-helm/compare/v0.3.3...).


This is related to #18226, which was fixed in #18252. The same "broken" logic is happening 50 lines below (.Target is an empy string):

<a href="{{$.RepoLink}}/compare/{{.TagName | PathEscapeSegments}}...{{.Target | PathEscapeSegments}}">

The same solution as in #18252 could be applied (stripping the ... from the href).

However I think it would be more useful to fall back to the repository default branch in such case (empty target field).

I would be willing to make a PR for such a "default branch fallback" solution.


Moreover the count of commits is different between the release list and the single release (tag v0.5.0 for instance):
https://codeberg.org/forgejo-contrib/forgejo-helm/releases
https://codeberg.org/forgejo-contrib/forgejo-helm/releases/tag/v0.5.0

=> commit count fixed in #24148


Original report: https://codeberg.org/Codeberg/Community/issues/967
Related fix for a woodpecker plugin: https://codeberg.org/woodpecker-plugins/gitea-release/pulls/9

Gitea Version

1.19 and 1.20

Can you reproduce the bug on the Gitea demo site?

Yes

How are you running Gitea?

On codeberg

contributed in the context of @forgejo

@viceice

This comment was marked as outdated.

@oliverpool
Copy link
Contributor Author

No. Both bug are related to the releases page counting commits, but have different reasons:

@lunny lunny modified the milestones: 1.19.2, 1.19.3 Apr 28, 2023
@lunny lunny modified the milestones: 1.19.3, 1.19.4 May 4, 2023
lunny pushed a commit that referenced this issue May 10, 2023
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.
oliverpool added a commit to oliverpool/gitea that referenced this issue May 11, 2023
Backport go-gitea#24470

Fixes go-gitea#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.
silverwind pushed a commit that referenced this issue May 12, 2023
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_
Codeberg-org pushed a commit to Codeberg-org/gitea that referenced this issue Jun 3, 2023
Backport go-gitea#24470

Fixes go-gitea#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 cb7ba89)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants