Skip to main content

Module tree_cleanup

Module tree_cleanup 

Source
Expand description

Deletes inside the working tree that lose no work: a build output directory, a scratch directory at the top of the tree, or a find cleanup of files a tool writes again. The static guard allows these, as ljos-policyd does, so a stock seat with no rules of its own does not stop rm -rf target/ or find . -name '*.pyc' -delete. The lists and the reading are the ones in ljos-policyd’s src/lib.rs; keep the two in step.

Functions§

build_output
A plain relative path inside a build output directory, or the directory itself: target/, ./build, web/node_modules. A path through .git is not one.
leaves_tree
A cd, pushd or popd that can leave the working tree: an absolute target, ~, -, .., a variable, or none at all (home). words is one command, wrappers already stripped.
regenerable_cleanup
A find cleanup inside the working tree: every starting point is . or a plain relative path outside .git, and every name test names a file in [REGENERABLE_NAMES], with at least one. An -o, a !, a -not or a group can turn a name test around, so none passes. find . -delete has no name test and find . -name '*.rs' -delete names source, so both stay refused.
scratch
A plain relative path under a scratch directory at the top of the tree, or the directory itself: tmp/, ./tmp/test-output. A scratch name deeper down (src/tmp) says nothing about what the path holds.