Skip to main content

Module excludes

Module excludes 

Source
Expand description

Exclude-pattern expansion and matching, plus the follow/no-follow setting.

The oracle (snapdir-manifest) applies excludes as an extended regular expression fed to grep -E -v: a path is excluded when the regex matches it. The user-supplied --exclude pattern may embed two macros that expand to built-in sets, lifted verbatim from _snapdir_manifest_define_exclude_patterns:

  • %system% expands to the system directory set and forces --no-follow.
  • %common% expands to the common directory set (.git, .cache, node_modules, .DS_Store, Trash dirs, …).

Per the library-purity principle, snapdir-core reads no environment. The oracle’s %system% set interpolates two runtime paths — ${HOME}/.cache/ and the resolved cache directory ${_SNAPDIR_MANIFEST_CACHE_DIR} — so those are passed in as parameters; the CLI lane resolves $HOME / XDG_CACHE_HOME and hands them to expand_excludes. The built-in literal sets themselves match the oracle’s hard-coded defaults (when SNAPDIR_SYSTEM_EXCLUDE_DIRS / SNAPDIR_COMMON_EXCLUDE_DIRS are unset).

The filesystem walk that actually consults ExcludeMatcher::is_excluded lands in a later gate; this module models the expansion + matcher + the follow/no-follow option semantics, validated against the Bash source.

Structs§

ExcludeMatcher
A compiled exclude matcher: a path is excluded when the (extended) regex matches anywhere in it, mirroring grep -E -v.
ExpandedExclude
The result of expanding a --exclude pattern: the final extended-regex string plus whether the expansion forced --no-follow.

Enums§

ExcludeError
Errors raised while expanding/compiling an exclude pattern.
FollowMode
Whether the filesystem walk follows symbolic links.

Constants§

COMMON_EXCLUDE_DIRS
The oracle’s default common exclude directory list — the body of SNAPDIR_COMMON_EXCLUDE_DIRS’s default.
SYSTEM_EXCLUDE_DIRS
The oracle’s default system exclude directory list — the body of SNAPDIR_SYSTEM_EXCLUDE_DIRS’s default (the leading-^-anchored set, excluding the trailing ${HOME}/.cache/ and cache-dir entries, which are runtime values appended in expand_excludes).

Functions§

expand_excludes
Expands the %system% / %common% macros in a --exclude pattern.