mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
First pass at adding a hook selector for files that contain a given string
This commit is contained in:
parent
6872289f1a
commit
82e1768656
6 changed files with 38 additions and 0 deletions
|
|
@ -1028,6 +1028,18 @@ def test_classifier_empty_types_or(tmpdir):
|
|||
assert for_file == ['bar']
|
||||
|
||||
|
||||
def test_classifier_files_contain(tmpdir):
|
||||
tmpdir.join('ignored').ensure().write('We\nIgnore\nThis\nFile\n')
|
||||
tmpdir.join('matched').ensure().write('We\nMatch\nThis\nFile\n')
|
||||
with tmpdir.as_cwd():
|
||||
classifier = Classifier(('ignored', 'matched'))
|
||||
files_contain = classifier.files_contain(
|
||||
classifier.filenames,
|
||||
contains='Match',
|
||||
)
|
||||
assert files_contain == ['matched']
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def some_filenames():
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -986,6 +986,7 @@ def test_manifest_hooks(tempdir_factory, store):
|
|||
exclude='^$',
|
||||
exclude_types=[],
|
||||
files='',
|
||||
files_contain='',
|
||||
id='bash_hook',
|
||||
language='script',
|
||||
language_version='default',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue