mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
Gitea incorrectly auto-closes issue even though referenced branch has not been merged yet #14268
Closed
opened 2025-11-02 11:08:03 -06:00 by GiteaMirror
·
13 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.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
v1.3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#14268
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @reimer-atb on GitHub (Mar 18, 2025).
Description
Gitea incorrectly auto-closes an issue if you force-push to a PR referencing that issue, even though the PR is still open and not merged into the main branch.
Steps to reproduce
Create a repo with a single file
README.md.Create issue "A" in that repo
Create a new branch "<issue_number>-A" for the issue, add some changes to
README.md, commit them with message "closes #<issue_number>" to enable auto-close when the branch is merged, and push itCreate a pull request based on branch "<issue_number>-A" above
Link the issue to the pull request branch "<issue_number>-A"
Create a second branch "B" based on "main", add a change to
README.mdthat conflicts with a change in branch "<issue_number>-A", and push itCreate a pull request for the second branch "B", and merge it using "Rebase
then fast-forward" and selecting "Delete Branch "B""
Pull the updated "main" branch locally, switch to branch "<issue_number>-A", and run
git rebase mainResolve the conflict in
README.mdkeeping both changes, and rungit add README.md, thengit rebase --continueRun
git push --force-with-leaseResult
Issue "A" is auto-closed (see https://demo.gitea.com/reimer-atb/test/issues/1)
even though the PR is still open and branch "<issue_number>-A" has not been merged into "main" (see https://demo.gitea.com/reimer-atb/test/pulls/2).
Expected result
Issue "A" should remain "open". It should only be auto-closed when the PR is merged into "main".
Gitea Version
1.23.5 and 1.24.0+dev-424-g403775e74e
Can you reproduce the bug on the Gitea demo site?
Yes
Log Gist
No response
Screenshots
No response
Git Version
2.49.0
Operating System
No response
How are you running Gitea?
I used demo.gitea.com. It also happens on our gitea instance (version 1.23.5). But I don't manage that and don't know what it runs on.
Database
None
@wxiaoguang commented on GitHub (Mar 18, 2025):
That branch selector does nothing more than just record/display a name. It affects nothing.
That's why I suggested to remove it, see the original proposal in "Fix bug of branch/tag selector in the issue sidebar #32744 "
@reimer-atb commented on GitHub (Mar 18, 2025):
It obviously causes a bug in the auto-closing issue feature. Because the issue is not auto-closed if I don't link the issue to the pull request branch.
While the mentioned PR may have been merged it does not seem to be included in any of the upcoming releases (1.23.6 or 1.24)?
There's also #20226 (included in the 1.24.0 milestone). Won't that require again a link between issue and pull request branch?
@wxiaoguang commented on GitHub (Mar 18, 2025):
Because that PR didn't really remove the selector. See its discussion, a user said that they still need that selector.
That's a new proposal
@reimer-atb commented on GitHub (Mar 18, 2025):
Then I don't understand the relevance for this issue? If the branch selector is not going to be removed then the bug I am describing here remains, and should be fixed.
@wxiaoguang commented on GitHub (Mar 18, 2025):
From my understanding:
I did a quick test, using that "branch selector" doesn't have any affect, it only shows a message like
root added reference root-patch-5 2 minutes agoand won't trigger "auto-close" feature.@wxiaoguang commented on GitHub (Mar 18, 2025):
Maybe the root cause is the
close #xxxphrases in commit message?@wxiaoguang commented on GitHub (Mar 19, 2025):
Hmm, I think I could overall understand the problem now.
It seems to be a feature from "Fix permission checks for close/reopen from commit (#8875)"
The logic is like this: if an issue
#Nrefers tobranch-X, andbranch-Xcontains commits likeclose #N, then when Gitea receives the commit, then it auto closes the issue#N.Actually you could also reproduce it by this step:
#Nbranch-X#Nrefer tobranch-Xclose #Ninbranch-Xand push#Nwill be closedI guess it can't be considered as a bug since it was designed to work that way, some users used to follow this workflow.
By the way, there is even an option in repo's setting page: "Close an issue via a commit made in a non default branch", it could close an issue by a commit in any branch (but not only the "referred" one) by
close #Nphrase.So maybe the solution is: do not use that branch selector if you don't need it .........
Related logic:
39fc2e7285/services/repository/push.go (L249)39fc2e7285/services/issue/commit.go (L199)@reimer-atb commented on GitHub (Mar 19, 2025):
The point is that I did not enable that setting. And therefore expected that having
closes #Nin a commit only closes the issue if the commit is on the default branch.At the very least, the wording of that option is not clear, and gitea's behavior is inconsistent. Because if I just do a normal push of a
closes #Ncommit to my non-defaultbranch-Xthe issue will be kept open. Only when I do a force-push to that branch after a rebase the issue get's auto-closed. That does not make any sense to me, in any workflow.@wxiaoguang commented on GitHub (Mar 19, 2025):
I did not say you enabled that setting. I was just explaining the whole design. I think I have said clearly that By the way (but not only ...).
Please read the explanation above again: a commit in branch
branch-Xcontainsclose #Nwill close the issue#Nif the issue has attached to branchbranch-Xby the sidebar branch selector. I was just explaining the old design.That's not true. A normal push also also behaves exactly the same: a commit in branch
branch-Xcontainsclose #Nwill close the issue#Nif the issue has attached to branchbranch-Xby the sidebar branch selector. You could try it by yourself without force-push.@wxiaoguang commented on GitHub (Mar 19, 2025):
And actually I do not know why you need that branch selector to choose a branch for an issue.
So quote the comment above:
If you really need it, could you help to elaborate your workflow?
@reimer-atb commented on GitHub (Mar 19, 2025):
I don't really need it. And yes, now that I know that the branch selection feature is causing the bug I can work around it and not use the branch selector.
But I don't understand what point you are trying to make here? Are you saying this is not a bug? Then I would strongly disagree.
As long as this branch selection feature exists some people will use it. And they will encounter this bug that I am describing. And they will become confused and frustrated with gitea.
@wxiaoguang commented on GitHub (Mar 19, 2025):
Then it comes to that background:
😆
In my mind that "branch selector" is an out-dated feature, it was designed that way so it's hard to say it is really a bug or not. But I failed to remove it because some users said they still need it .....
As an open-source and crowd-contributed project, many features were written in old days and the original author maintainers are not active anymore. I am just trying to clarify everything at the moment.
To be honest, I don't quite understand how to correctly maintain this feature to satisfy every user.
@GiteaBot commented on GitHub (Apr 19, 2025):
We close issues that need feedback from the author if there were no new comments for a month. 🍵