~/bend-docscommunity

src/ledger/ignore.bend fails

raw source on the hub · import ezx@1.10.0.0/src/ledger/ignore.bend as Ignore

ledger/ignore: the gitignore allowlist, derived from the ledger. A dependency marked vendor = true has its tree committed under .ez/lib/<hash>, and git only keeps it when .gitignore says so with a !.ez/lib/<hash> line. That line has to follow the ledger exactly: a hash the ledger stopped naming leaves a dead tree committed, and one it names but the file does not is a tree a clone never gets. So the allowlist is not edited, it is derived: sync takes the ledger's dependencies and the file, and gives back the file whose allowlist lines are exactly the vendored hashes, with every line that is not ez's left as it was. ez add, ez remove and ez lock --upgrade all write what it returns.

Which lines are ez's. A line that starts !.ez/lib/ is ez's allowlist, as written, and whatever follows the prefix is the hash it names. Anything else is read loosely: surrounding blanks trimmed, one leading / and one trailing / dropped, so !/.ez/lib/<h>/ and !.ez/lib/<h> are allowlist lines too. ez owns everything under .ez/lib, so any exception under it is ez's to keep or drop; a line spelled differently from allow is dropped and the hash, when the ledger still vendors it, written back in the canonical spelling. Three more lines are what makes the allowlist work at all: .ez/*, !.ez/lib and .ez/lib/*. Git cannot re-include a file under a directory it excluded, so a bare .ez/ (or .ez, /.ez/) makes every allowlist line inert. That line is replaced, where it stands, by whichever of the three the file does not already have.

Where the allowlist goes. The vendored hashes are written as one block, each once, in the order the ledger first names them, where the file's first allowlist line was. A file with none gets the block at its end, which is where the upgrade has always appended one, preceded by whichever of the three rules the file lacks.

2 imports
import Base
import ./manifest.bend as M