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 31, 2022
1 parent 855ae81 commit 545b51e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,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
9 changes: 7 additions & 2 deletions codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,14 @@ 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
Expand Down

0 comments on commit 545b51e

Please sign in to comment.