Skip to main content

Module fetcher

Module fetcher 

Source
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:

pinnetwork needed to resolve
rev = full 40-hex SHAnone
tag (exact or prefix) / branch / no pinone ls-remote (ref listing, no objects)
rev = short SHA / revspecfalls 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:

  1. SSH agent (Cred::ssh_key_from_agent) — tried only when the remote advertises SSH_KEY in allowed_types.
  2. Credential helper (Cred::credential_helper) — tried when USER_PASS_PLAINTEXT is advertised.
  3. Cred::default() — last resort.

The callback tracks attempted credential types to avoid infinite retry loops.

Structs§

FetchedPkg
Result of a successful Fetcher::fetch call.
GitFetcher
Fetcher implementation backed by libgit2.

Traits§

Fetcher
Abstraction over package fetch backends.