Specific configurations for files that need no EOF

Pre-commit by default adds a single `\n` EOF to all files, but we have some tests that make sure that isn't done by Copier itself.

This specific behavior is committed separately to keep track of it. I'm adding an exclusion filter for files named `whatever.noeof.suffix`, and those are skipped by the `end-of-file-fixer` hook.

Also tests had to be changed accordingly. Nothing too special.
This commit is contained in:
Jairo Llopis 2019-11-21 11:45:47 +00:00
parent a549638c3c
commit 2ff11656e2
10 changed files with 15 additions and 10 deletions

View File

@ -32,6 +32,8 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
# Some tests require no EOF or they will fail
exclude: \.noeof\.
- id: debug-statements
- id: flake8
additional_dependencies:

View File

@ -1,2 +1,2 @@
_skip_if_exists:
- "a.txt"
- "a.noeof.txt"

View File

@ -0,0 +1 @@
OVERWRITTEN

View File

@ -1 +0,0 @@
OVERWRITTEN

View File

@ -74,12 +74,15 @@ def test_exclude_file(dst):
def test_skip_if_exists(dst):
copier.copy("tests/demo_skip_dst", dst)
copier.copy(
"tests/demo_skip_src", dst, skip_if_exists=["b.txt", "meh/c.txt"], force=True
"tests/demo_skip_src",
dst,
skip_if_exists=["b.noeof.txt", "meh/c.noeof.txt"],
force=True,
)
assert (dst / "a.txt").read_text() == "OVERWRITTEN"
assert (dst / "b.txt").read_text() == "SKIPPED"
assert (dst / "meh" / "c.txt").read_text() == "SKIPPED"
assert (dst / "a.noeof.txt").read_text() == "OVERWRITTEN"
assert (dst / "b.noeof.txt").read_text() == "SKIPPED"
assert (dst / "meh" / "c.noeof.txt").read_text() == "SKIPPED"
def test_skip_if_exists_rendered_patterns(dst):
@ -88,12 +91,12 @@ def test_skip_if_exists_rendered_patterns(dst):
"tests/demo_skip_src",
dst,
data={"name": "meh"},
skip_if_exists=["[[ name ]]/c.txt"],
skip_if_exists=["[[ name ]]/c.noeof.txt"],
force=True,
)
assert (dst / "a.txt").read_text() == "OVERWRITTEN"
assert (dst / "b.txt").read_text() == "OVERWRITTEN"
assert (dst / "meh" / "c.txt").read_text() == "SKIPPED"
assert (dst / "a.noeof.txt").read_text() == "OVERWRITTEN"
assert (dst / "b.noeof.txt").read_text() == "OVERWRITTEN"
assert (dst / "meh" / "c.noeof.txt").read_text() == "SKIPPED"
def test_config_exclude(dst, monkeypatch):