Expand description
Git-based package fetcher.
The Fetcher trait abstracts over different fetch backends (git, luarocks,
http). GitFetcher implements the git backend using libgit2 via the
git2 crate. No subprocess git invocations are used.
§Cache layout
<cache_root>/git/<host>/<path…>/<sha>/For example, https://github.com/ynishi/lshape at SHA abc123 becomes:
<cache_root>/git/github.com/ynishi/lshape/abc123/§Cache hit without a clone
Before cloning, the ref is resolved cheaply:
| pin | network needed to resolve |
|---|---|
rev = full 40-hex SHA | none |
tag (exact or prefix) / branch / no pin | one ls-remote (ref listing, no objects) |
rev = short SHA / revspec | falls through to a clone |
If <cache_root>/git/<host>/<path…>/<sha>/ already exists for the
resolved SHA, that directory is returned as is and no clone happens.
Only a cache miss pays for a full clone (into a temp dir, then renamed
into place).
§Authentication
GitFetcher uses a RemoteCallbacks-based credential cascade:
- SSH agent (
Cred::ssh_key_from_agent) — tried only when the remote advertisesSSH_KEYinallowed_types. - Credential helper (
Cred::credential_helper) — tried whenUSER_PASS_PLAINTEXTis advertised. Cred::default()— last resort.
The callback tracks attempted credential types to avoid infinite retry loops.
Structs§
- Fetched
Pkg - Result of a successful
Fetcher::fetchcall. - GitFetcher
Fetcherimplementation backed by libgit2.
Traits§
- Fetcher
- Abstraction over package fetch backends.