Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: release page for empty or non-existing target #24470

Merged
merged 4 commits into from May 10, 2023

Conversation

oliverpool
Copy link
Contributor

@oliverpool oliverpool commented May 1, 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.

contributed in the context of @forgejo

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 1, 2023
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 1, 2023
@silverwind silverwind added this to the 1.20.0 milestone May 1, 2023
@6543 6543 added the outdated/backport/v1.19 This PR should be backported to Gitea 1.19 label May 4, 2023
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 9, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 10, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 10, 2023
@lunny lunny merged commit 8030614 into go-gitea:main May 10, 2023
15 checks passed
@GiteaBot
Copy link
Contributor

I was unable to create a backport for 1.19. @oliverpool, please send one manually. 🍵

@GiteaBot GiteaBot added backport/manual No power to the bots! Create your backport yourself! and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels May 10, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request May 10, 2023
* upstream/main:
  Remove unnecessary code (go-gitea#24610)
  Fix commits pushed with deploy keys not shown in dashboard (go-gitea#24521)
  fix: release page for empty or non-existing target (go-gitea#24470)
  Filter get single commit (go-gitea#24613)
  Attach a tooltip to the action status icon (go-gitea#24614)
  Use official Vue extension in Gitpod (go-gitea#24609)
  Create a branch directly from commit on the create branch API (go-gitea#22956)
  Make repository response support HTTP range request (go-gitea#24592)
oliverpool added a commit to oliverpool/gitea that referenced this pull request 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.
@oliverpool
Copy link
Contributor Author

oliverpool commented May 11, 2023

Backport created: #24659

It would be even nicer if the bot could write:

please send one manually, for instance by running:

go run ./contrib/backport/backport.go 24470`
// fix eventual git conflicts
go run ./contrib/backport/backport.go --continue

@oliverpool oliverpool deleted the fix_release_empty_target branch May 11, 2023 08:05
@silverwind
Copy link
Member

silverwind commented May 11, 2023

Backport created: #24659

It would be even nicer if the bot could write:

please send one manually, for instance by running:

go run ./contrib/backport/backport.go 24470`
// fix eventual git conflicts
go run ./contrib/backport/backport.go --continue

Raise issue here: https://github.com/GiteaBot/gitea-backporter/issues

@oliverpool
Copy link
Contributor Author

@silverwind thanks for the hint, I opened an issue (I had no idea where the bot code was located :)

@yardenshoham yardenshoham added the backport/done All backports for this PR have been created label May 11, 2023
silverwind pushed a commit that referenced this pull request 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 pull request 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)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Aug 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. outdated/backport/v1.19 This PR should be backported to Gitea 1.19 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Commits since this release' link broken for API created releases
6 participants