Skip to content

Commit

Permalink
skip files passed in if matching the skip glob
Browse files Browse the repository at this point in the history
  • Loading branch information
bwitt committed May 4, 2021
1 parent a65c8c0 commit 19c223f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ def main(*args):
# skip (relative) directories
dirs[:] = [dir_ for dir_ in dirs if not glob_match.match(dir_)]

else:
elif not glob_match.match(filename): # skip files
bad_count += parse_file(
filename, colors, summary, misspellings, exclude_lines,
file_opener, word_regex, ignore_word_regex, context, options)
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 @@ -288,10 +288,12 @@ def test_encoding(tmpdir, capsys):
def test_ignore(tmpdir, capsys):
"""Test ignoring of files and directories."""
d = str(tmpdir)
with open(op.join(d, 'good.txt'), 'w') as f:
goodtxt = op.join(d, 'good.txt')
with open(goodtxt, 'w') as f:
f.write('this file is okay')
assert cs.main(d) == 0
with open(op.join(d, 'bad.txt'), 'w') as f:
badtxt = op.join(d, 'bad.txt')
with open(badtxt, 'w') as f:
f.write('abandonned')
assert cs.main(d) == 1
assert cs.main('--skip=bad*', d) == 0
Expand All @@ -305,6 +307,9 @@ def test_ignore(tmpdir, capsys):
assert cs.main('--skip=*ignoredir*', d) == 1
assert cs.main('--skip=ignoredir', d) == 1
assert cs.main('--skip=*ignoredir/bad*', d) == 1
badjs = op.join(d, 'bad.js')
copyfile(badtxt, badjs)
assert cs.main('--skip=*.js', goodtxt, badtxt, badjs) == 1


def test_check_filename(tmpdir, capsys):
Expand Down

0 comments on commit 19c223f

Please sign in to comment.