Expand description
Working out where the repositories are, without being told.
devp init <path> has always registered a whole tree at once, but somebody has to
know which tree to name. That is a fine thing to ask of a person setting their own
machine up and a bad thing to ask of an assistant driving the tool on their behalf:
an agent that has to guess ~/Code guesses wrong on the machine that keeps its work
on D:\, and the repositories it never found are the ones that go on wasting disk.
So the roots are derived rather than guessed, from two sources that cost nothing:
- The neighbourhood. People keep repositories next to each other. The parent of every registered repository is therefore a place where more of them probably live, and rescanning those parents is how registering one project ends up finding the rest of the workspace around it. This is the source that works on any layout, including drives and directory names no list could have anticipated.
- The working directory. Bare
devp initalready scans., so the workspace the command was run from is evidence that costs nothing in surprise — and it is the only evidence there is on a cold start where the code lives on a second drive. - The conventions. A machine with an empty registry has no neighbourhood yet, so
constants::CODE_ROOT_NAMESis probed by name under the home directory. This is only ever the bootstrap: one registered repository anywhere makes source 1 better than this one will ever be.
Discovery registers. It does not delete, and nothing here shortens the distance
between “registered” and “pruned”: a discovered repository still has to go idle, still
has to have every candidate directory proved recoverable by a lockfile, and still has
to clear all seven safety invariants before anything is removed. That is what makes
registering by itself a safe thing to do — the worst outcome of a wrong guess is a row
in devp status.
Structs§
- Discovery
- What one discovery pass found.
Functions§
- candidate_
roots - Every root worth walking, with the ones contained in another root removed.
- discover
- Look for repositories this registry does not know about.
- discover_
in - The body of
discover, with the roots supplied rather than derived. - neighbourhood_
roots - The parent directory of every registered repository, where that parent is deep enough to be a workspace rather than a home directory or a drive root.