makeprov.forges

Functions

dataclass([cls, init, repr, eq, order, ...])

Add dunder methods based on the fields defined in the class.

load_forges([extra])

Load the built-in profiles, preceded by any user-supplied ones.

lru_cache([maxsize, typed])

Least-recently-used cache decorator.

normalize_remote(origin)

Return (host, repo_url) for a git remote, or None if unparseable.

resolve_forge(origin[, profiles])

Match a git remote against the known forges.

urlsplit(url[, scheme, allow_fragments])

Parse a URL into 5 components: <scheme>://<netloc>/<path>?<query>#<fragment>

Classes

ForgeProfile(name, hosts, blob)

How one git host builds a permalink to a file at a revision.

Path(*args, **kwargs)

PurePath subclass that can make system calls.

class makeprov.forges.ForgeProfile(name, hosts, blob)

Bases: object

How one git host builds a permalink to a file at a revision.

blob: str
blob_prefix(repo, revision)
Return type:

str

hosts: tuple[str, ...]
name: str
makeprov.forges.load_forges(extra=None)

Load the built-in profiles, preceded by any user-supplied ones.

User profiles are matched first so they can override a built-in host, which is what self-hosted instances of a known forge need.

Return type:

tuple[ForgeProfile, ...]

makeprov.forges.normalize_remote(origin)

Return (host, repo_url) for a git remote, or None if unparseable.

Handles both URL and scp-style remotes, and drops any userinfo: a remote like https://user:token@host/o/r.git must never put its credentials into a provenance document.

Return type:

tuple[str, str] | None

makeprov.forges.resolve_forge(origin, profiles=None)

Match a git remote against the known forges.

Returns the matching profile and the normalized repository URL, or None when the remote is unparseable or its host is not a known forge.

Return type:

tuple[ForgeProfile, str] | None