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

Protect repositories #3

Open
2 of 4 tasks
Crocmagnon opened this issue Mar 15, 2024 · 5 comments
Open
2 of 4 tasks

Protect repositories #3

Crocmagnon opened this issue Mar 15, 2024 · 5 comments
Assignees

Comments

@Crocmagnon
Copy link

Crocmagnon commented Mar 15, 2024

Hello! Thank you for this nice tool, I wanted to do some cleanup in my forks but unfortunately I'd need some more features to use it.

There are many reasons a fork may need to stay even if it's old. Maybe a branch is unmerged and we're still working on it, maybe a PR is open waiting for a review.
It also appears that the tool only filters forks by their createdAt date.
I'm actively working on a fork and I regularly push commits & branches and they get merged regularly, so I don't want to delete this fork.

I suggest adding several features to make the tool useful to more people:

  • protecting some repositories manually, because we may want to keep them even if all other "protections" fail
  • protecting repositories based on last activity instead of creation date
  • protecting repositories based on open PRs in the upstream repo
  • protecting repositories based on unmerged branches (with recent activity?)

The output should mention clearly why a repo is being protected or if it's being deleted (or would be, in case the -delete flag is not provided).

@Crocmagnon Crocmagnon changed the title Check for open PR and/or unmerged branches Protect repositories Mar 15, 2024
@rednafi
Copy link
Owner

rednafi commented Mar 15, 2024

Thank you for the ideas; they are great!

I really like the idea of deleting repositories based on the last activity date, rather than the creation date. This can be done without changing the external flag.

Also, a --protect flag that will take a list of repositories sounds useful.

I'll start tackling tasks from the lowest level of complexity to the highest. Also, feel free to open a PR if you have strong opinions about the implementation.

@rednafi
Copy link
Owner

rednafi commented Mar 18, 2024

Version 0.2.0 now:

  • Fetches forked repos based on pushed_at || updated_at || created_at date.

  • Lists the forked repositories that will and won't be deleted:

    fork-sweeper --owner rednafi --token $GITHUB_TOKEN --older-than-days 0

    This returns:

    Fetching forked repositories for rednafi...
    
    Guarded forked repos [won't be deleted]:
    
    Unguarded forked repos [will be deleted]:
        - https://github.com/rednafi/cpython
        - https://github.com/rednafi/dysconfig
        - https://github.com/rednafi/pydantic
  • Explicitly filter out forked repositories with fuzzy name matching:

    fork-sweeper --owner "rednafi" --token $GITHUB_TOKEN --older-than-days 0 --guard 'py'

    This prints:

      Fetching forked repositories for rednafi...
    
      Guarded forked repos [won't be deleted]:
          - https://github.com/rednafi/cpython
          - https://github.com/rednafi/pydantic
    
      Unguarded forked repos [will be deleted]:
          - https://github.com/rednafi/dysconfig

@rednafi rednafi closed this as completed Mar 18, 2024
rednafi added a commit that referenced this issue Mar 18, 2024
@Crocmagnon
Copy link
Author

Nice ! 😀
I think however the biggest value would come from an "open PR" guard. It may require some more work though as I don't know if this information can easily be obtained with GitHub's API.
Also, listing why repos are protected would be a good addition too IMO.

@rednafi
Copy link
Owner

rednafi commented Mar 18, 2024

Yeah, a PR guard would be nice I agree. But at the same time, it's hard to track that without consuming some event.

Listing why a repo was filtered out seems like an easy low-hanging fruit.

@rednafi rednafi reopened this Mar 18, 2024
@Crocmagnon
Copy link
Author

After doing some exploration, it looks like the open PR feature can be implemented quite easily with the GraphQL API but would require several calls with the REST API.
There’s a discussion on the refined-github repo about this, specifically this comment: refined-github/refined-github#2268 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants