rednafi / fork-sweeper

Remove unused GitHub forks
23 stars 0 forks source link

Protect repositories #3

Open Crocmagnon opened 7 months ago

Crocmagnon commented 7 months ago

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).

rednafi commented 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.

rednafi commented 7 months ago

Version 0.2.0 now:

Crocmagnon commented 7 months ago

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 commented 7 months ago

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.

Crocmagnon commented 7 months ago

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