caarlos0 / fork-cleaner Goto Github PK
View Code? Open in Web Editor NEWQuickly clean up unused forks on your github account.
License: MIT License
Quickly clean up unused forks on your github account.
License: MIT License
example:
Error gathering the repository list: failed to compare repository with upstream: skrashevich/qbittorrent: GET https://api.github.com/repos/hotio/qbittorrent/compare/master...skrashevich:svk: 404 No common ancestor between master and skrashevich:svk. [].
Having an issue with the snap package:
paulius@mini:~$ sudo snap install fork-cleaner
[sudo] password for paulius:
fork-cleaner 2.2.1 from Carlos Alexandro Becker (caarlos0) installed
paulius@mini:~$ fork-cleaner --token 1ZkjBjiBZxk....
open fork-cleaner.log: permission denied
Versions:
paulius@mini:~$ snap --version
snap 2.57.1
snapd 2.57.1
series 16
ubuntu 22.04
kernel 5.15.0-47-generic
๐๐ฝ heyo, neat tool!
Running the tool on a fork of a SAML repo results in the following error message:
Error gathering the repository list: failed to get repository's issues: CamiloGarciaLaRotta/rest-api-description: GET https://api.github.com/repos/github/rest-api-description/issues?creator=CamiloGarciaLaRotta&per_page=100: 403 Resource protected by organization SAML enforcement. You must grant your Personal Access token access to this organization. [].
Check the log file for more details.
A couple of things:
The good news is that once the PAT is authorized it works as expected ๐
$ GOPATH=`pwd` go get github.com/caarlos0/fork-cleaner
bin/fork-cleaner # github.com/caarlos0/fork-cleaner/internal/cleaner
src/github.com/caarlos0/fork-cleaner/internal/cleaner/repos.go:12: not enough arguments in call to client.Repositories.Delete
have (string, string)
want (context.Context, string, string)
src/github.com/caarlos0/fork-cleaner/internal/cleaner/repos.go:27: not enough arguments in call to client.Repositories.List
have (string, *github.RepositoryListOptions)
want (context.Context, string, *github.RepositoryListOptions)
Even with the confirmation message Remove the above listed forks?
, I have an uncertain feeling. To prevent the worst from happening I'd suggest adding a --backup
parameter, which simply clones every to be deleted repository to a specified folder.
E.g.
โ fork-cleaner --token <MY_TOKEN> --backup /tmp/repo-backup
2 forks to delete:
--> https://github.com/BrunnerLivio/repo-1
--> https://github.com/BrunnerLivio/repo-2
Remove the above listed forks? (y/n) [n]: y
Forks have been backed up in /tmp/ repo-backup
Forks removed!
โ tree /tmp/repo-backup
repo-backup
โโโ repo-1
โโโ repo-2
Hello, cool tool! I was looking to build something similar, but:
Therefore, I think I would like to expand upon this tool. But before I start contributing PR's, i want to see if these ideas make sense.
Concretely, here's what I think:
visual indicator (via color or emoji) whether a fork is safe to delete (while keeping what you have: selecting the fork shows more details)
the rules whether a fork is safe to delete, would be as follows:
a) for forks on github:
b) for forks on disk: the above, plus:
to keep things simple, the app would probably either scan GH forks, or on disk forks, not both at once.
if you forked a repo on GH, and then cloned that code to your disk, it's possible the local fork only has a remote for the GH fork, and not for the upstream. so to keep things simple, you would probably clean up your on-disk forks first, before cleaning GH forks.
which file paths to scan on disk: i see two options:
$GOPATH/src/github.com/*/*
, this would avoid that problem, although it might result in "argument list too long"Hi,
thank you for fork-cleaner!
Sometimes I may fork repos at some point in time and its upstream fork then gets deleted, thus I'd like to keep these repos for archival purposes. I didn't check the code but this condition doesn't seem to be explicitly mentioned in the README, will these forks be deleted too?
Often forks contain branches with changes. It appears only the default branch is used. If so it would be better to check all branches to see if the commit is merged upstream.
For example, I had a fork (https://github.com/Maxim-Mazurok/Instagram-API) of the project (https://github.com/mgp25/Instagram-API) that is taken down by DMCA:
When running fork-cleaner, I was getting this error:
GET https://api.github.com/repos/Maxim-Mazurok/Instagram-API: 451 Repository access blocked []
Line 58 in f0c3318
fork-cleaner/cmd/fork-cleaner/main.go
Lines 32 to 37 in c4aed77
TODO
comment in c4aed77. It's been assigned to @caarlos0 because they committed the code.When the list of forks is longer than one screen it is not displayed correctly, and scrolling doesn't work properly.
This is awesome; I would love to be able to use this on my corporate GitHub Enterprise account. Would it be possible to add an argument flag or a config file option to point to something other than api.github.com?
./fork-cleaner --token "my_token"
GET https://api.github.com/api/v3/user/repos?affiliation=owner&per_page=100: 404 Not Found []
accessing the same URL via browser, I get this response:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest"
}
Hi, thanks very much for this lib.
Even if it was not updated after a month, it the fork holds a pull request to upstream, it would be better not to delete it. Some PRs may take long time to be reviewed, but still require changes before a merge.
Alternatively, the cli could accept a --exclude
flag, to blacklist some repos. Example:
fork-cleaner --token "..." --exclude="a-repo,another-repo,third-repo"
I get this error for one of the forks I have:
Error gathering the repository list: failed to compare repository with upstream: jack1142/compose: GET https://api.github.com/repos/docker/compose/compare/v2...jack1142:master: 404 No common ancestor between v2 and jack1142:master. [].
It appears that this fork has been created when a different branch was the default branch and the branch that is now the default branch is completely new (created without a base, e.g. with --orphan
).
are even with or behind the upstream repo (customizable via --exclude-commits-ahead).
I managed to spot it before I hit "yes sir!", but would not expect this repo to be included:
I have a repo named gulp-es5validate, which is forked from an upstream repo named gulp-jsvalidate.
Running fork-cleaner --token <token>
produces the following error message and an exit status of 1:
GET https://api.github.com/repos/sindresorhus/gulp-es5validate/compare/master...rwhogg:master: 404 Not Found []
Blacklisting the repo by either name does not change the result.
To be clear, I don't want to delete this fork, but this error prevents me from seeing others that I might want to.
Error gathering the repository list: failed to get repository: : GET https://api.github.com/repos/pokurt/genshin-impact-helper: 403 Repository access b Check the log file for more details.
api responded with:
{
"message": "Repository access blocked",
"block": {
"reason": "tos",
"created_at": "2021-06-08T01:02:15Z",
"html_url": "https://github.com/tos"
}
}```
I know it has been taken down by github. i want it to be deleted or ignored
Hi @caarlos0, thanks for the tool! FYI it was added to Homebrew/homebrew-core in Homebrew/homebrew-core#27805 so you can remove it from your tap if you desire.
When running dep ensure
we receive the following warning:
==> dep ensure
dep: WARNING: unknown field in manifest: dependencies
Just wanted to let you know. Thanks again!
I wish I had some output or anything to share with you but, I went to delete a repo and fork-cleaner hung after confirmation. I'm on an M1 Mac (maybe that's the problem ยฏ\_(ใ)_/ยฏ) and the token provided was generated using the link in the README.
After generating a token with all repo and delete repo access
Running:
fork-cleaner --token 878678dfeae463e33bb735209bd164844de1d224
Returns the following error:
Get "https://api.github.com/user/repos?affiliation=owner&per_page=100": dial tcp: lookup api.github.com on [::1]:53: dial udp [::1]:53: socket: permission denied
Note that I have since removed this access token
Hey! Thanks so much for this project, definitely makes my life easier after having >100 forks in my profile.
It looks like a lot of my forks have been starred or forked for some reason:
https://github.com/The-Compiler/4chan-x excluded because: repo has 1 stars
https://github.com/The-Compiler/astroid excluded because: repo has 1 stars
https://github.com/The-Compiler/awesome-for-beginners excluded because: repo has 3 stars
https://github.com/The-Compiler/bryan.sh excluded because: repo has 1 stars
https://github.com/The-Compiler/cheroot excluded because: repo has 1 stars
https://github.com/The-Compiler/cope excluded because: repo has 1 stars
https://github.com/The-Compiler/fahrplan excluded because: repo has 1 stars
https://github.com/The-Compiler/gabelstaplerwm excluded because: repo has 1 stars
https://github.com/The-Compiler/hypothesis-training excluded because: repo has 1 stars
https://github.com/The-Compiler/LibrePCB excluded because: repo has 1 stars
https://github.com/The-Compiler/markupsafe excluded because: repo has 1 stars
https://github.com/The-Compiler/nixpkgs excluded because: repo has 1 stars
https://github.com/The-Compiler/odoo excluded because: repo has 1 forks
https://github.com/The-Compiler/pyqtconsole excluded because: repo has 1 stars
https://github.com/The-Compiler/pytest excluded because: repo has 1 forks
https://github.com/The-Compiler/pytest-bdd excluded because: repo has 1 stars
https://github.com/The-Compiler/pytest-html excluded because: repo has 1 forks
https://github.com/The-Compiler/pytest-mock excluded because: repo has 1 forks
https://github.com/The-Compiler/python-conference-beginners-day excluded because: repo has 1 stars
https://github.com/The-Compiler/pyyaml excluded because: repo has 1 stars
https://github.com/The-Compiler/qutebrowser-zotero excluded because: repo has 1 stars
https://github.com/The-Compiler/rofimoji excluded because: repo has 1 stars
https://github.com/The-Compiler/solarized-everything-css excluded because: repo has 1 stars
https://github.com/The-Compiler/Stikked excluded because: repo has 1 forks
https://github.com/The-Compiler/TreeNote excluded because: repo has 3 stars
https://github.com/The-Compiler/UserScripts excluded because: repo has 1 stars
https://github.com/The-Compiler/vimium excluded because: repo has 1 stars
https://github.com/The-Compiler/webkit excluded because: repo has 1 stars
https://github.com/The-Compiler/xournal excluded because: repo has 2 stars
https://github.com/The-Compiler/YCM-Generator excluded because: repo has 1 stars
I'm not sure why that is, all those have been forked in the past just for some (long merged) PRs. Thus, it'd be nice if I had a commandline flag to also include them, rather than having to delete them manually.
Not sure what happened, but when I run it, it exits after printing this:
GET https://api.github.com/repos/caddyserver/caddy/compare/master...bep:master: 404 No common ancestor between master and bep:master. []
I have plenty of other forks (I may have the world record in forks).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.