module

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_repos(token : String) : Array(Repo)

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)

Source
env_bool(name : String, default : Bool) : Bool
Source
git_auth_env(token : String) : Hash(String, String)
Source
load_state(path : Path) : MirrorState
Source
main
Source
now_iso
Source
read_token
Source
run_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.

Source
select_repos(repos : Array(Repo), include_forks : Bool, include_archived : Bool) : Array(Repo)
Source
sync_repo(repo : Repo, mirror_root : Path, env : Hash(String, String), timeout : Int32 | Nil, fetch_lfs : Bool) : Bool
Source