Expand description
Repository discovery: the nearest ancestor of the start directory that carries
.ai/manifest.yaml is the root, and the manifest is the only thing read to find it.
.git is not a marker: an arbitrary git repository is not a Majordomus repository. A
.majordomus/ directory is not a marker either; it is an optional installation of the
tool, or the pre-.ai layout, which is refused by name.
§Why the marker is the manifest
Every other candidate marker is ambiguous. .git says a directory is version
controlled, which almost every directory a person runs this in will be; a .ai
directory alone says nothing about whether it is this layer. The manifest declares its
own schema, so discovery either finds a layer this executable can read or it says which
schema it found and which it reads — never a half-open repository.
§Errors
crate::Error::RepositoryNotFound when no ancestor carries the manifest, naming where
the search began; crate::Error::LegacyLayout when it finds the pre-.ai layout,
naming the migration; and the manifest’s own parse and schema errors, each naming the
file. None of them is a diagnostic: without a manifest nothing can be discovered at all.
use majordomus_cli::Repository;
// a directory that is not a repository is an error that says where it looked
let empty = tempfile::tempdir().unwrap();
let err = Repository::discover(empty.path()).unwrap_err();
assert!(matches!(err, majordomus_cli::Error::RepositoryNotFound { .. }));
assert_eq!(err.exit_code(), 12, "the code for something that is not there");
// and a git repository is not one either: the marker is the manifest and nothing else
std::fs::create_dir(empty.path().join(".git")).unwrap();
assert!(Repository::discover(empty.path()).is_err());Structs§
- Context
Conventions - The scoped context documents: file names that must carry the context contract
(
schema: context/v1) wherever they appear under the layer. - GitIdentity
- The git repository a checkout belongs to, as distinct from the checkout itself.
- Local
Half - The checkout-local half of the layer, never a source.
- Manifest
.ai/manifest.yaml, typed. Unknown keys are refused throughshare/allow/manifest.txt.- Repo
Half - The tracked half of the layer.
- Repository
- A located repository with its manifest read.
Constants§
- LAYER_
SCHEMA - The layer schema this executable reads.
- MANIFEST
- The file whose presence makes a directory the root of a Majordomus repository.
Functions§
- branch_
at - The branch the checkout at
roothas checked out, read from itsHEADfile instead of asked of a subprocess.Nonewhen HEAD is detached, when the file cannot be read, or whenrootis not a checkout at all — the same three silencesgit symbolic-ref -q --short HEADanswers with, at the cost of at most two small reads. - git_
identity - Ask git which repository the checkout at
rootbelongs to. One subprocess;Nonewhen git is absent or the root is not a work tree. - identity
- A repository’s identity over the wire: a digest of its absolute root.