Skip to content

patterns: clean up TODOs, move is_include_cmd to IECommand property, fixes #9442#9542

Open
mr-raj12 wants to merge 1 commit intoborgbackup:masterfrom
mr-raj12:cleanup-patterns-todos-master
Open

patterns: clean up TODOs, move is_include_cmd to IECommand property, fixes #9442#9542
mr-raj12 wants to merge 1 commit intoborgbackup:masterfrom
mr-raj12:cleanup-patterns-todos-master

Conversation

@mr-raj12
Copy link
Contributor

Description

Address the TODO items in src/borg/patterns.py as discussed in #9442:

  1. recurse_dir_default: Replaced the misleading TODO with a comment explaining why it must stay True as include patterns inside excluded directories (+ inside -) depend on it.

  2. is_include_cmd: Moved from a dict on PatternMatcher to an is_include property on IECommand and now the matcher calls cmd.is_include instead of doing a dict lookup.

  3. RootPath validation: Added a warning when the root path doesn't start with /, so backups don't fail due to a typo.

  4. command_recurses_dir: Replaced cmd not in [IECommand.ExcludeNoRecurse] with explicit if/raise branches using is comparisons. Now raises ValueError for unexpected commands like RootPath or PatternStyle.

Tests updated to use real IECommand values and cover the new code paths.

Checklist

  • PR is against master
  • New code has tests and docs where appropriate
  • Tests pass
  • Commit messages are clean and reference related issues

@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.41%. Comparing base (9d5687d) to head (0a1d559).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/patterns.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9542      +/-   ##
==========================================
+ Coverage   83.39%   83.41%   +0.01%     
==========================================
  Files          87       87              
  Lines       15469    15479      +10     
  Branches     2321     2324       +3     
==========================================
+ Hits        12901    12912      +11     
+ Misses       1818     1817       -1     
  Partials      750      750              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant