Code Monkey home page Code Monkey logo

Comments (8)

IvanZosimov avatar IvanZosimov commented on August 27, 2024

Hi, @MichaelJJ 👋 Thanks for the bug report, we will take a look at it and get back to you with updates!

from stale.

dsame avatar dsame commented on August 27, 2024

Hello @MichaelJJ,

While trying to reproduce the problem it occurred to me i did not understand the issue well.

the branch is from a fork according to the description literally means a branch of the other repo used to create a PR

So can the desired behaviour be said as "do not attempt to delete the branches for the staled PR"?

from stale.

MichaelJJ avatar MichaelJJ commented on August 27, 2024

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 pullRequest.head.ref will simply return test-branch, which may result in deleting a branch that should not be removed.

from stale.

dsame avatar dsame commented on August 27, 2024

@MichaelJJ , and here we are
https://github.com/actions/stale/pull/913/files#diff-93e32a46e13f11c2066be36506b0f153d7da2b6b8d787da9177c10692ce50fc5R926

The idea is: delete the branch if

  • pullRequest.head.repo === null -- PR's branch is not forked
    or
  • pullRequest.head.repo.full_name === '${context.repo.owner}/${context.repo.repo}' - PR is from the same repo

Do you think we are on the same page?

from stale.

MichaelJJ avatar MichaelJJ commented on August 27, 2024

I think that would cover it, the branch would only be deleted if the PR head is the repo, and not a fork. Thanks!

from stale.

dsame avatar dsame commented on August 27, 2024

@MichaelJJ The related PR merged and can be used immediately with

- uses: actions/stale@main

from stale.

dsame avatar dsame commented on August 27, 2024

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.

from stale.

panticmilos avatar panticmilos commented on August 27, 2024

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?

from stale.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.