Skip to content

Commit

Permalink
Skip subdirectories of hidden directories
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Oct 20, 2022
1 parent a050986 commit f79ce79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,9 @@ def main(*args):
uri_ignore_words, context, options)

# skip (relative) directories
dirs[:] = [dir_ for dir_ in dirs if not glob_match.match(dir_)]
dirs[:] = [dir_ for dir_ in dirs
if not glob_match.match(dir_)
and not is_hidden(dir_, options.check_hidden)]

elif not glob_match.match(filename): # skip files
bad_count += parse_file(
Expand Down
13 changes: 9 additions & 4 deletions codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,17 @@ def test_check_hidden(tmpdir, capsys):
assert cs.main(d) == 0
assert cs.main('--check-hidden', d) == 1
assert cs.main('--check-hidden', '--check-filenames', d) == 2
os.mkdir(op.join(d, '.abandonned'))
hidden_dir = op.join(d, '.abandonned')
os.mkdir(hidden_dir)
copyfile(op.join(d, '.abandonned.txt'),
op.join(d, '.abandonned', 'abandonned.txt'))
op.join(hidden_dir, 'abandonned.txt'))
hidden_subdir = op.join(hidden_dir, 'subdir')
os.mkdir(hidden_subdir)
copyfile(op.join(d, '.abandonned.txt'),
op.join(hidden_subdir, 'abandonned.txt'))
assert cs.main(d) == 0
assert cs.main('--check-hidden', d) == 2
assert cs.main('--check-hidden', '--check-filenames', d) == 5
assert cs.main('--check-hidden', d) == 3
assert cs.main('--check-hidden', '--check-filenames', d) == 8


def test_case_handling(tmpdir, capsys):
Expand Down

0 comments on commit f79ce79

Please sign in to comment.