-
Notifications
You must be signed in to change notification settings - Fork 364
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
Delete branch option does not appear to respect forks #881
Comments
Hi, @MichaelJJ 👋 Thanks for the bug report, we will take a look at it and get back to you with updates! |
Hello @MichaelJJ, While trying to reproduce the problem it occurred to me i did not understand the issue well.
So can the desired behaviour be said as "do not attempt to delete the branches for the staled PR"? |
I believe the simplest fix would be to check if the PR head is a fork repository, skip branch deletion for that PR even if the option is enabled. Here is an example: I fork a repo, and commit changes to a branch named "test-branch" on the Fork. I create a Pull Request from Fork branch "test" to the parent (original) repo. The Pull Request becomes stale, and I have the delete branch option enabled. When the stale job runs, it closes the Pull Request in the parent (original) repo and then attempts to delete a branch named "test-branch" in Repo A, even though the PR branch originates from a fork. If you look at the code here: https://github.com/actions/stale/blob/main/src/classes/issues-processor.ts#L923 it is simply looking for the PR branch name, and should also be checking if the PR originates from a fork. If my PR head is "ForkA:test-branch", the code |
@MichaelJJ , and here we are The idea is: delete the branch if
Do you think we are on the same page? |
I think that would cover it, the branch would only be deleted if the PR head is the repo, and not a fork. Thanks! |
@MichaelJJ The related PR merged and can be used immediately with
|
Hello @MichaelJJ , i am closing the issue because the related PR has been merged, but please feel free to reopen it or create new one if the problem still exists. |
hi @MichaelJJ, we have released a new major version of action, that is including a fix for this issue. Could you confirm everything works as expected? |
Describe your issue
It appears that the delete branch option does not identify if the branch is from a fork and will attempt to delete a branch with the same name in the parent repository.
Further context
As an example, if I fork a repository, the PR branch will be
my-fork:main
. If delete branch is true, then the stale action will attempt to delete branchmain
in the parent (primary) repo.The stale action should check if the closed PR branch is a fork and either skip branch deletion, or attempt to delete the branch in the fork.
Looking at the code https://github.com/actions/stale/blob/main/src/classes/issues-processor.ts#L923 the action is simply taking
pullRequest.head.ref
which is simply the branch name and does not give an indication if this is a fork repo branch. The payload appears to have several ways to detect if this branch is from a fork, includingpullRequest.head.repo.fork: true
or checkingpullRequest.head.repo.owner
.The text was updated successfully, but these errors were encountered: