Skip to content

Commit 2dc276d

Browse files
committed
fix(extra-fixed-nested-sentinels): Skip sentinel exclusions under configured extra fixed directories.
- Filter sentinel matches beneath extra fixed directories before individual exclusions. - Apply the filtering when built-in fixed directories are enabled or disabled. - Add behavior tests for extra fixed directories in both configuration modes. - Document the redundant exclusion fix in the changelog.
1 parent b2a6a83 commit 2dc276d

3 files changed

Lines changed: 44 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1717

1818
### Fixed
1919

20+
- Sentinel matches nested under directories configured with `[fixed_dirs] extra` are now
21+
skipped, avoiding redundant per-directory Time Machine exclusions before the configured
22+
parent directory is excluded ([#132](https://github.com/AsimovMac/asimov/issues/132)).
23+
2024
### Removed
2125

2226
## [0.12.0] — 2026-07-30

lib/asimov/exclude.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,24 @@ exclude_paths_from_stdin() {
7171
fi
7272
verbose_timing "Filtered: ${#to_exclude[@]} new, ${already_excluded} already excluded"
7373

74-
# Layer 2: Filter descendants of ASIMOV_FIXED_DIRS — they'll be excluded
75-
# unconditionally later, so calling tmutil on them individually is wasted (~11s each).
76-
if [[ "$ASIMOV_CONFIG_FIXED_DIRS_ENABLED" == "true" && ${#to_exclude[@]} -gt 0 ]]; then
74+
# Layer 2: Filter descendants of enabled built-in fixed dirs and configured
75+
# extra fixed dirs — they'll be excluded unconditionally later, so calling
76+
# tmutil on them individually is wasted (~11s each).
77+
local -a effective_fixed_dirs=()
78+
if [[ "$ASIMOV_CONFIG_FIXED_DIRS_ENABLED" == "true" ]]; then
79+
effective_fixed_dirs=("${ASIMOV_FIXED_DIRS[@]}")
80+
fi
81+
local configured_fixed_dir
82+
for configured_fixed_dir in ${ASIMOV_CONFIG_EXTRA_FIXED_DIRS[@]+"${ASIMOV_CONFIG_EXTRA_FIXED_DIRS[@]}"}; do
83+
effective_fixed_dirs+=("$configured_fixed_dir")
84+
done
85+
86+
if [[ ${#effective_fixed_dirs[@]} -gt 0 && ${#to_exclude[@]} -gt 0 ]]; then
7787
local -a filtered_exclude=()
7888
for path in "${to_exclude[@]}"; do
7989
local under_fixed=false
8090
local fixed_dir
81-
for fixed_dir in "${ASIMOV_FIXED_DIRS[@]}"; do
91+
for fixed_dir in "${effective_fixed_dirs[@]}"; do
8292
if [[ "$path" == "${fixed_dir}/"* ]]; then
8393
under_fixed=true
8494
break

tests/behavior.bats

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,32 @@ extra = ~/.cache-b"
370370
assert_excluded "${HOME}/.cache-b"
371371
}
372372

373+
@test "config: extra fixed dir suppresses nested sentinel exclusions when fixed dirs enabled" {
374+
create_project ".custom-cache/My-Project" "package.json" "node_modules"
375+
write_config "[fixed_dirs]
376+
enabled = true
377+
extra = ~/.custom-cache"
378+
379+
run_asimov --no-cache
380+
381+
assert_excluded "${HOME}/.custom-cache"
382+
refute_excluded "${HOME}/.custom-cache/My-Project/node_modules"
383+
[[ "$(count_exclusions)" -eq 1 ]]
384+
}
385+
386+
@test "config: extra fixed dir suppresses nested sentinel exclusions when fixed dirs disabled" {
387+
create_project ".custom-cache/My-Project" "package.json" "node_modules"
388+
write_config "[fixed_dirs]
389+
enabled = false
390+
extra = ~/.custom-cache"
391+
392+
run_asimov --no-cache
393+
394+
assert_excluded "${HOME}/.custom-cache"
395+
refute_excluded "${HOME}/.custom-cache/My-Project/node_modules"
396+
[[ "$(count_exclusions)" -eq 1 ]]
397+
}
398+
373399
@test "config: extra sentinel pair triggers exclusion" {
374400
create_project "Code/My-Project" "custom.config" ".custom-deps"
375401
write_config "[sentinels]

0 commit comments

Comments
 (0)