lang::lock
lang/src/lock.mo
pub type GitPin {
tag (name : String),
branch (name : String),
rev (id : String),
head,
}What a git entry was asked to follow. head is the remote's default
branch: a dependency that named no tag, branch or rev.
pub struct LockedGit {
url : String,
pin : GitPin,
commit : String,
/// The mote's directory inside the checkout. TOML text in the lock
/// file; a `Path` once read, because that is what resolution joins.
subdir : Option Path,
}The git half of a lock entry. commit is always a full id: a tag or
branch is resolved once, by monad fetch, and never moves afterwards.
pub struct LockedMote {
name : String,
version : String,
checksum : String,
git : Option LockedGit,
}One [[mote]] entry. checksum is sha256:<hex> over the canonical
tree digest of the mote's directory (ยง2b). git is none for a source
that is not a git checkout.
pub struct Lockfile {
motes : List LockedMote,
}pub type LockRead {
loaded (lock : Lockfile),
unsupported (version : I64),
}A successfully read mote.lock: either one this reader understands, or
the version it does not -- which the caller warns about and
regenerates rather than failing on.
pub def parse (text : String) : Result String LockReadParse mote.lock text. err carries a message naming what is wrong.
pub def subdir_path (o : Option String) : Option PathA lock file's git_subdir is TOML text; this is the one conversion
into a Path. Path.unsafe and not Path.of: an empty git_subdir
parses today and must keep parsing (the renderer round-trips it), and
a lockfile's subdir is validated where it is USED
(Build.safe_subdir), not where it is read.
pub def pin_of (s : String) : Option GitPintag:<name> / branch:<name> / rev:<id> / head. An empty name
is no pin at all, so it is rejected with the rest.
pub def pin_to_string (p : GitPin) : Stringgit_ref's spelling of a pin; the inverse of pin_of.
pub def is_commit (s : String) : BoolSHA-1 repositories have 40-digit ids, SHA-256 ones 64. Public
because build::git resolves a rev against exactly this rule --
one definition, so a commit the lock accepts is a commit the
transport will look up.
pub def render (lock : Lockfile) : StringThe lockfile's text. Deterministic for a given set of entries, whatever order they arrive in.
pub def source_of (g : LockedGit) : Stringgit+<url>?tag=v1&subdir=x#<commit>: the display spelling only.
pub def read (path : Path) : IO (Result String (Option LockRead))Read the lockfile at path: none when there is none (the ordinary
first-fetch case), err when it exists but cannot be read or parsed.
pub def write (path : Path) (lock : Lockfile) : IO (Result String Unit)Write lock to path, replacing whatever is there.