Skip to main content

Module clone

Module clone 

Source
Expand description

Config-driven clone with explicit flag placement, built-in stateless steps, and pre/post-clone hooks.

Per repo, in order: global pre-clone → repo pre-clonegit <PRE> clone <POST> <url> <dir> → built-ins (git identity + submodule branch-switch + direnv allow) → global post-clone → repo post-clone.

Git identity (user.name/user.email) is per-invocation, not in the conf (the conf is shared across a team): it comes from Opts (the clone --user-name/--user-email flags, or an interactive prompt), and is stamped git config on each cloned repo right after clone so post-clone hooks see it.

The git clone and built-ins are captured (clean status; an .envrc that runs glow … can’t distort output — direnv allow only records trust). User hooks run via sh -c with their output inherited (explicit commands, shown live) and $GKIT_REPO/GKIT_DIR/GKIT_URL/GKIT_HOST/GKIT_NAMESPACE set (plus GKIT_USER_NAME/GKIT_USER_EMAIL, empty when no identity was given).

Structs§

CloneReport
Opts

Enums§

Outcome

Functions§

clone_all
Clone every repo in conf, printing each step in order. Returns a report per repo (for the aggregate exit code).
distinct_namespaces
Distinct namespaces across a conf’s repos (each repo’s effective namespace), in conf order, deduplicated — one insteadOf rule is written per distinct namespace.
insteadof_pair
The git-config (key, value) for the namespace-scoped insteadOf rewrite that lets a canonical submodule URL route through the alias’s key: key = url.<alias>:<ns>/.insteadOf value = git@<hostname>:<ns>/ so git rewrites git@<hostname>:<ns>/repo.git<alias>:<ns>/repo.gitid_<alias>. The trailing / on both sides scopes the rule to the namespace (so multiple aliases on the same host — different clients — each keep their own key).