Skip to content

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

Merged
ThomasWaldmann merged 1 commit intoborgbackup:masterfrom
mr-raj12:cleanup-patterns-todos-master
Mar 29, 2026
Merged

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

Conversation

@mr-raj12
Copy link
Copy Markdown
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
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.36%. Comparing base (9d5687d) to head (60596bd).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/borg/patterns.py 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9542      +/-   ##
==========================================
- Coverage   83.39%   83.36%   -0.04%     
==========================================
  Files          87       87              
  Lines       15469    15481      +12     
  Branches     2321     2325       +4     
==========================================
+ Hits        12901    12906       +5     
- Misses       1818     1821       +3     
- Partials      750      754       +4     

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

@mr-raj12 mr-raj12 force-pushed the cleanup-patterns-todos-master branch from 6d42b24 to 13c7df2 Compare March 25, 2026 19:41
@mr-raj12 mr-raj12 force-pushed the cleanup-patterns-todos-master branch from 13c7df2 to 60596bd Compare March 27, 2026 23:06
Copy link
Copy Markdown
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ThomasWaldmann ThomasWaldmann merged commit 78b4aac into borgbackup:master Mar 29, 2026
31 of 34 checks passed
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.

2 participants