fix(cli): ignore generated folders in subfolders
Build and Push Docker Container / build-and-push (push) Successful in 3m12s

- Match directory ignore patterns against every path segment.
- Prevent nested .comments folders from uploading XML sidecar files.
- Bump the standalone CLI to 0.4.2 for the ignore fix.
This commit is contained in:
2026-07-28 00:14:00 +02:00
parent 08d0d154c9
commit d3e5e11f8d
3 changed files with 6 additions and 1 deletions
+2
View File
@@ -46,6 +46,8 @@ def is_ignored(rel_path: str, patterns: list[str]) -> bool:
if pattern.endswith('/'):
if path == normalized or path.startswith(f'{normalized}/'):
return True
if any(fnmatch(part, normalized) for part in parts):
return True
continue
if '/' in normalized:
if fnmatch(path, normalized):
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "nanoshare-cli"
version = "0.4.1"
version = "0.4.2"
description = "NanoShare desktop CLI and folder sync client"
readme = "README.md"
requires-python = ">=3.11"
+3
View File
@@ -213,6 +213,8 @@ def test_sync_ignores_local_files_from_nanoshareignore(tmp_path, monkeypatch):
(tmp_path / 'scratch.tmp').write_text('ignored')
(tmp_path / '.comments').mkdir()
(tmp_path / '.comments' / 'ignored.xml').write_text('<comment />')
(tmp_path / 'Cerberus' / '.comments').mkdir(parents=True)
(tmp_path / 'Cerberus' / '.comments' / '76. Two-headeds.PNG.xml').write_text('<comment />')
(tmp_path / '.env').write_text('SECRET=ignored')
(tmp_path / '.venv').mkdir()
(tmp_path / '.venv' / 'ignored.py').write_text('ignored')
@@ -261,6 +263,7 @@ def test_default_ignore_patterns_skip_common_generated_files(tmp_path):
patterns = load_ignore_patterns(tmp_path)
assert is_ignored('.comments/comment.xml', patterns)
assert is_ignored('Cerberus/.comments/76. Two-headeds.PNG.xml', patterns)
assert is_ignored('.env', patterns)
assert is_ignored('.env.local', patterns)
assert is_ignored('.venv/bin/python', patterns)