Code Monkey home page Code Monkey logo

fork-cleaner's Introduction

Hi there ๐Ÿ‘‹

I'm Carlos, I write and operate software for a living.

๐Ÿ‘จโ€๐Ÿ’ป Repositories I created recently

โค๏ธ Recent Sponsors

Many thanks everyone! ๐Ÿ™

โ›๏ธ What I've been working on

๐Ÿ“š Books I'm reading

You might want to check out my books wishlist and my literal.club profile as well.

๐Ÿ“„ Latest blog posts

fork-cleaner's People

Contributors

bfontaine avatar caarlos0 avatar chrismckee avatar dependabot-preview[bot] avatar dependabot[bot] avatar dieterbe avatar happyfacade avatar ilmanzo avatar j178 avatar jakewarren avatar mar10p avatar meowgorithm avatar mikemcquaid avatar rwhogg avatar the-compiler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fork-cleaner's Issues

socket :: permission denied

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

`dep ensure` warning

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!

discussion: local (on disk) forks + highlighting when is it "safe" to delete a repo (fork)?

Hello, cool tool! I was looking to build something similar, but:

  1. for cleaning up checked out repositories on my laptop
  2. in a way that uses less "mental work" for the user of the tool. I don't want to have to manually review every single repository and read the text, because sometime the text is "benign" (like my fork has stars), and sometimes it is of vital importance (like my fork has unmerged commits)

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:

  1. visual indicator (via color or emoji) whether a fork is safe to delete (while keeping what you have: selecting the fork shows more details)

  2. the rules whether a fork is safe to delete, would be as follows:

    a) for forks on github:

    • no commits that are not pushed upstream (in any branch)

    b) for forks on disk: the above, plus:

    • working copy is not "dirty" (i tend to create todo files, notes, or code files that is often not comitted)
    • index is empty
    • "git stash" is empty
  3. to keep things simple, the app would probably either scan GH forks, or on disk forks, not both at once.

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

  5. which file paths to scan on disk: i see two options:

  • provide a parent path, and process all git repos inside it, but some code repositories have other "sub git repositories" as part of their build process, or vendored code, so keeping the behavior proper, seems a bit tricky
  • rely on shell expansion to provide an explicit list of all git repos to process, like $GOPATH/src/github.com/*/*, this would avoid that problem, although it might result in "argument list too long"

Do not delete forks with open upstream pull requests?

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"

Repository comparison fail when default branches have no common ancestor

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

Hangs on repo delete

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.

go-get fails

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

Feature: branches should be compared

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.

Exclude forks where its upstream is deleted?

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?

403 Repository access b Check the log file for more details.

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

open fork-cleaner.log: permission denied

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

public SAML repo forks break the CLI

๐Ÿ‘‹๐Ÿฝ heyo, neat tool!

What

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 organization for which to authorize the PAT is not present in the list
  • it would be neat if one could still access forks from non SAML orgs. I don't necessarily want to authorize the PAT for every org
  • the log file is empty

The good news is that once the PAT is authorized it works as expected ๐ŸŽ‰

404 not found

./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"
}

Add --backup parameter to backup the to-be-deleted forks

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

Feature request: GHE

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?

Add a flag to include starred/forked repos

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.

Fails if you have a forked repo with a different name from its upstream

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.

Fails with 404

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

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.