GithubMirror
Constants
GITHUB_API = "https://api.github.com"
USAGE = "Usage: github-mirror [--version | --help]\n\nMaintains bare mirrors of every GitHub repository a token can see.\nThere are no flags for normal operation; everything is configured\nthrough environment variables:\n\n GH_TOKEN_FILE (required) file containing a GitHub token\n MIRROR_DIR directory the mirrors are written into [/data]\n GIT_TIMEOUT per-git-invocation timeout in seconds [none]\n INCLUDE_FORKS also mirror forks [false]\n INCLUDE_ARCHIVED also mirror archived repos [true]\n FETCH_LFS also fetch Git LFS objects [false]\n GH_AFFILIATION owner | collaborator | organization_member [owner]\n GH_VISIBILITY all | public | private [all]\n\nExit codes: 0 all repos mirrored, 1 a repo or the enumeration failed,\n2 configuration error."
VERSION = "0.1.1"
Instance methods
Enumerate every repo the token can see, following pagination to exhaustion Any API failure is fatal: abort rather than risk acting on a partial or empty list (can't list repos must never be read as not having any repos)
main
Sourcenow_iso
SourceReturns the rel="next" URL from a GitHub Link header, or nil when there's no next page (ending pagination loop)
read_token
Sourcerun_git(args : Array(String), env : Hash(String, String), timeout : Int32 | Nil) : Tuple(Bool, String)
Run a git subprocess with the given environment. Returns {success, error}.
TODO: cancel the timeout timer on completion before adding the concurrent clone pool. As written, a fast-finishing git leaves a fiber sleeping the full timeout; harmless when sequential, but N sleepers accumulate under concurrency. Replace with a Channel/select-based cancellation then.