Open Crocmagnon opened 7 months ago
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.
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
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.
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.
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: https://github.com/refined-github/refined-github/issues/2268#issuecomment-562495007
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:
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).