Skip to content

Commit 7cb0f15

Browse files
committed
fix ignoring; simplify global ignoring patterns
1 parent 1e9de19 commit 7cb0f15

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

cycode/cli/files_collector/walk_ignore.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
_SUPPORTED_IGNORE_PATTERN_FILES = {'.gitignore', '.cycodeignore'}
1212
_DEFAULT_GLOBAL_IGNORE_PATTERNS = [
13-
'.git',
14-
'.cycode',
15-
'**/.git/**',
16-
'**/.cycode/**',
13+
'**/.git',
14+
'**/.cycode',
1715
]
1816

1917

@@ -67,7 +65,7 @@ def walk_ignore(path: str) -> List[str]:
6765

6866
# decrease recursion depth of os.walk() because of topdown=True by changing the list in-place
6967
# slicing ([:]) is mandatory to change dict in-place!
70-
dirnames[:] = [d for d in dirnames if _should_include_path(ignore_patterns, d)]
71-
filenames[:] = [f for f in filenames if _should_include_path(ignore_patterns, f)]
68+
dirnames[:] = [d for d in dirnames if _should_include_path(ignore_patterns, os.path.join(dirpath, d))]
69+
filenames[:] = [f for f in filenames if _should_include_path(ignore_patterns, os.path.join(dirpath, f))]
7270

7371
yield dirpath, dirnames, filenames

tests/cli/files_collector/test_walk_ignore.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,10 @@ def test_get_global_ignore_patterns(fs: 'FakeFilesystem') -> None:
8787
_create_mocked_file_structure(fs)
8888
ignore_patterns = _get_global_ignore_patterns('/home/user/project/subdir')
8989

90-
assert len(ignore_patterns) == 7
90+
assert len(ignore_patterns) == 5
9191
# default global:
92-
assert '.git' in ignore_patterns
93-
assert '.cycode' in ignore_patterns
94-
assert '**/.git/**' in ignore_patterns
95-
assert '**/.cycode/**' in ignore_patterns
92+
assert '**/.git' in ignore_patterns
93+
assert '**/.cycode' in ignore_patterns
9694
# additional:
9795
assert '*.txt' in ignore_patterns
9896
assert '*.pyc' in ignore_patterns

0 commit comments

Comments
 (0)