Handle gitignore negations #23

Merged
mdk merged 16 commits from maciek/potodo:handle-gitignore-negation into main 2025-10-16 16:06:25 +02:00
Contributor

Presence of negations in gitignore requires different applying of rules. This different applying is present in gitignore_parser library in _parse_gitignore_lines() function, which is not used by potodo. I used code from that function in potodo's build_ignore_matcher() function. Confirmed it works as expected (below).

Before (now) % potodo --show-finished --exclude **/* '!bugs.po' '!tutorial/*' '!library/functions.po' returns nothing, not taking negations into account.

After, negations are accounted for:

% potodo --show-finished --exclude **/* '!bugs.po' '!tutorial/*' '!library/functions.po' 


# python-docs-pl (100.00% done)

- bugs.po                         30 /  30 (100.0% translated).


# library (98.07% done)

- functions.po                   508 / 518 ( 98.0% translated).


# tutorial (98.09% done)

- appendix.po                     27 /  28 ( 96.0% translated).
- appetite.po                     17 /  17 (100.0% translated).
- classes.po                     148 / 149 ( 99.0% translated).
- controlflow.po                 219 / 226 ( 96.0% translated).
- datastructures.po              124 / 125 ( 99.0% translated).
- errors.po                       92 /  96 ( 95.0% translated).
- floatingpoint.po                76 /  76 (100.0% translated).
- index.po                         7 /   9 ( 77.0% translated).
- inputoutput.po                 111 / 112 ( 99.0% translated).
- interactive.po                   6 /   7 ( 85.0% translated).
- interpreter.po                  31 /  33 ( 93.0% translated).
- introduction.po                119 / 120 ( 99.0% translated).
- modules.po                     115 / 117 ( 98.0% translated).
- stdlib.po                       66 /  67 ( 98.0% translated).
- stdlib2.po                      64 /  65 ( 98.0% translated).
- venv.po                         42 /  42 (100.0% translated).
- whatnow.po                      18 /  18 (100.0% translated).


# TOTAL (98.11% done)
Presence of negations in gitignore requires different applying of rules. This different applying is present in gitignore_parser library in [`_parse_gitignore_lines()` function](https://github.com/mherrmann/gitignore_parser/blob/1db5f1b46ffedc4ccca330e08c4b416e3a79fe88/gitignore_parser.py#L35-L40), which is not used by potodo. I used code from that function in potodo's `build_ignore_matcher()` function. Confirmed it works as expected (below). Before (now) `% potodo --show-finished --exclude **/* '!bugs.po' '!tutorial/*' '!library/functions.po'` returns nothing, not taking negations into account. After, negations are accounted for: ```zsh % potodo --show-finished --exclude **/* '!bugs.po' '!tutorial/*' '!library/functions.po' # python-docs-pl (100.00% done) - bugs.po 30 / 30 (100.0% translated). # library (98.07% done) - functions.po 508 / 518 ( 98.0% translated). # tutorial (98.09% done) - appendix.po 27 / 28 ( 96.0% translated). - appetite.po 17 / 17 (100.0% translated). - classes.po 148 / 149 ( 99.0% translated). - controlflow.po 219 / 226 ( 96.0% translated). - datastructures.po 124 / 125 ( 99.0% translated). - errors.po 92 / 96 ( 95.0% translated). - floatingpoint.po 76 / 76 (100.0% translated). - index.po 7 / 9 ( 77.0% translated). - inputoutput.po 111 / 112 ( 99.0% translated). - interactive.po 6 / 7 ( 85.0% translated). - interpreter.po 31 / 33 ( 93.0% translated). - introduction.po 119 / 120 ( 99.0% translated). - modules.po 115 / 117 ( 98.0% translated). - stdlib.po 66 / 67 ( 98.0% translated). - stdlib2.po 64 / 65 ( 98.0% translated). - venv.po 42 / 42 (100.0% translated). - whatnow.po 18 / 18 (100.0% translated). # TOTAL (98.11% done) ```
mdk merged commit 9c566ded90 into main 2025-10-10 14:38:47 +02:00
mdk deleted branch handle-gitignore-negation 2025-10-10 14:38:48 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AFPy/potodo!23
No description provided.