Skip to content

Commit

Permalink
Standardize EOF newlines (cookiecutter#1876)
Browse files Browse the repository at this point in the history
* Add a pre-commit hook to standardize EOF newlines

* Run `pre-commit run --all-files end-of-file-fixer`

This is an automated change. Nothing was manually modified.

* Resolve test failures caused by standardized EOF newlines
  • Loading branch information
kurtmckee authored Jun 30, 2023
1 parent 2125335 commit e02de10
Show file tree
Hide file tree
Showing 33 changed files with 34 additions and 36 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@
```
// REPLACE ME: Paste a log of command(s) you ran and cookiecutter's output, tracebacks, etc, here
```

3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ repos:
args:
- "--fix=crlf"
files: "crlf"
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
Expand Down Expand Up @@ -65,4 +66,4 @@ repos:
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
- id: check-manifest
1 change: 0 additions & 1 deletion docs/advanced/boolean_variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ If a non valid value is inserted to a boolean field, the following error will be
run_as_docker [True]: docker
Error: docker is not a valid boolean
1 change: 0 additions & 1 deletion docs/advanced/local_extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,3 @@ This snippet will achieve the exact same result as the previous one.

For complex use cases, a python module ``local_extensions`` (a folder with an ``__init__.py``) can also be created in the template root.
Here, for example, a module ``main.py`` would have to export all extensions with ``from .main import FoobarExtension, simplefilterextension`` or ``from .main import *`` in the ``__init__.py``.

2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ myst-parser>=0.17.2
sphinx-autobuild>=2021.3.14
Sphinx>=4.5.0
sphinxcontrib-apidoc>=0.3.0
sphinx-autodoc-typehints>=1.18.2
sphinx-autodoc-typehints>=1.18.2
1 change: 0 additions & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,3 @@ Pre-0.7.0, this is how it worked:
is output to your current directory.

* Cloned cookiecutters were not saved locally.

2 changes: 1 addition & 1 deletion tests/fake-repo-bad/no-project-in-here.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Ha ha ha!
Ha ha ha!
2 changes: 1 addition & 1 deletion tests/files/syntax_error.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
I eat {{ syntax_error }} {# this comment is not closed}
I eat {{ syntax_error }} {# this comment is not closed}
2 changes: 1 addition & 1 deletion tests/files/unicode.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Polish: Ą Ł Ż
Chinese: 倀 倁 倂 倃 倄 倅 倆 倇 倈
Musical Notes: ♬ ♫ ♯
Musical Notes: ♬ ♫ ♯
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Testing that generate_file was {{ cookiecutter.generate_file }}
Testing that generate_file was {{ cookiecutter.generate_file }}
2 changes: 1 addition & 1 deletion tests/files/{{cookiecutter.generate_file}}.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Testing {{ cookiecutter.generate_file }}
Testing {{ cookiecutter.generate_file }}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ uuid4() }}
{{ uuid4() }}
2 changes: 1 addition & 1 deletion tests/test-generate-files-nontemplated/input/simple.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
I eat {{ food }}
I eat {{ food }}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Some static text
Some static text
Original file line number Diff line number Diff line change
@@ -1 +1 @@
I eat {{ cookiecutter.food }}
I eat {{ cookiecutter.food }}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
The color is {{ cookiecutter.color }} and the letter is {{ cookiecutter.letter }}.
The color is {{ cookiecutter.color }} and the letter is {{ cookiecutter.letter }}.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Hi!
My name is {{ cookiecutter.full_name }}.
It is {{ cookiecutter.year }}.
It is {{ cookiecutter.year }}.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pip
{% include 'click-requirements.jinja' %}{% endif %}
{% if cookiecutter.use_pytest == 'y' -%}
{% include 'pytest-requirements.jinja' %}{% endif %}
{% block dependencies %}{% endblock %}
{% block dependencies %}{% endblock %}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Click
Click
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pytest
pytest
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{% extends "base-requirements.jinja" %}
{% extends "base-requirements.jinja" %}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Click
Click
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pytest
pytest
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pip
{% if cookiecutter.command_line_interface|lower == 'click' -%}
{% include 'click-requirements.jinja' %}{% endif %}
{% if cookiecutter.use_pytest == 'y' -%}
{% include 'pytest-requirements.jinja' %}{% endif %}
{% include 'pytest-requirements.jinja' %}{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pip
{% if cookiecutter.command_line_interface|lower == 'click' -%}
Click{% endif %}
{% if cookiecutter.use_pytest == 'y' -%}
pytest{% endif %}
pytest{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pip
{%- block dev_dependencies %}
{% if cookiecutter.use_pytest == 'y' -%}{% include 'pytest-requirements.jinja' %}{% endif %}
{%- endblock %}
{% block dependencies %}{% endblock %}
{% block dependencies %}{% endblock %}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Click
Click
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pytest
pytest
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% extends "base-requirements.jinja" %}
{% block dev_dependencies %}{{ super() }}{% endblock %}
{% block dev_dependencies %}{{ super() }}{% endblock %}
4 changes: 2 additions & 2 deletions tests/test_default_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ def test_jinja2_uuid_extension(tmp_path):
assert os.path.isfile(changelog_file)

with Path(changelog_file).open(encoding='utf-8') as f:
changelog_lines = f.readlines()
changelog_lines = f.read().strip()

uuid.UUID(changelog_lines[0], version=4)
uuid.UUID(changelog_lines, version=4)
4 changes: 2 additions & 2 deletions tests/test_generate_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_generate_files(tmp_path):
assert simple_file.is_file()

simple_text = Path(simple_file).read_text(encoding='utf-8')
assert simple_text == 'I eat pizzä'
assert simple_text == 'I eat pizzä\n'


def test_generate_files_with_linux_newline(tmp_path):
Expand Down Expand Up @@ -305,7 +305,7 @@ def test_generate_files_with_overwrite_if_exists(tmp_path):
assert Path(simple_with_new_line_file).exists()

simple_text = Path(simple_file).read_text(encoding='utf-8')
assert simple_text == 'I eat pizzä'
assert simple_text == 'I eat pizzä\n'


@pytest.fixture
Expand Down
5 changes: 3 additions & 2 deletions tests/test_output_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ def test_output_folder():

something = """Hi!
My name is Audrey Greenfeld.
It is 2014."""
It is 2014.
"""
something2 = Path('output_folder/something.txt').read_text()
assert something == something2

in_folder = "The color is green and the letter is D."
in_folder = "The color is green and the letter is D.\n"
in_folder2 = Path('output_folder/folder/in_folder.txt').read_text()
assert in_folder == in_folder2

Expand Down
2 changes: 1 addition & 1 deletion tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_build_templates(template, output_dir):

readme = Path(project_dir, 'requirements.txt').read_text()

assert readme.splitlines() == [
assert readme.split() == [
"pip",
"Click",
"pytest",
Expand Down

0 comments on commit e02de10

Please sign in to comment.