Skip to main content

configured

Function configured 

Source
pub(crate) fn configured(want: &str) -> Option<String>
Expand description

One key out of the nearest .choir/config.

Generalised from the node lookup when the credential gained the same need: a checkout that names its node and a checkout that names the credential for it are the same question asked twice, and two parsers for one file is one of them drifting. The walk order, stated once so the surface can quote it: every .choir/config from the working directory up to the filesystem root, then ~/.choir/config.

The home file is the fallback and not the first stop, so a checkout that names its own node still wins on a machine that has joined a different one. It exists because the walk alone cannot answer for a contributor who joins in one directory and clones into another: ~/src/foo is not under ~ in any sense the walk can see once they have cd’d into it — it is, but only because $HOME happens to be a parent, which stops being true the moment they clone into /srv or onto another volume.

The alternative considered was writing the node into each clone at clone time through the credential helper. It was rejected because git gives a helper no hook that fires on git clone — the helper is asked for a credential, not told a repository was created — so the write would have to happen on the first authenticated fetch, which is after the contributor has already run a command that needed it.