Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: End of line detection and configuration. (#1407)
Co-authored-by: Philippe Ombredanne <pombredanne@nexb.com> Co-authored-by: Francisco Molina <franciscojose.molina@alten.es>
- Loading branch information
1 parent
f85bada
commit 8a07cac
Showing
20 changed files
with
285 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
* text=auto | ||
# CRLF sets for test files! Or tests will fail on CI/CD | ||
*crlf.txt text eol=crlf | ||
simple-with-newline-crlf.txt text eol=crlf | ||
simple-with-newline.txt text eol=lf | ||
*_crlf_newlines.txt text eol=crlf | ||
*_lf_newlines.txt text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ nosetests.xml | |
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
.pytest_cache | ||
|
||
# Translations | ||
*.mo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.. _new-lines: | ||
|
||
Working with line-ends special symbols LF/CRLF | ||
---------------------------------------------- | ||
|
||
*New in Cookiecutter 2.0* | ||
|
||
Before version 2.0 Cookiecutter silently used system line end character. | ||
LF for POSIX and CRLF for Windows. Since version 2.0 this behaviour changed | ||
and now can be forced at template level. | ||
|
||
By default Cookiecutter now check every file at render stage and use same line | ||
end as in source. This allow template developers to have both types of files in | ||
the same template. Developers should correctly configure their `.gitattributes` | ||
file to avoid line-end character overwrite by git. | ||
|
||
Special template variable `_new_lines` was added in Cookiecutter 2.0. | ||
Acceptable variables: `'\n\r'` for CRLF and `'\n'` for POSIX. | ||
|
||
Here is example how to force line endings to CRLF on any deployment:: | ||
|
||
{ | ||
"project_slug": "sample", | ||
"_new_lines": "\n\r" | ||
} |
1 change: 1 addition & 0 deletions
1
tests/files/{% if cookiecutter.generate_file == 'y' %}cheese.txt{% endif %}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Testing that generate_file was {{ cookiecutter.generate_file }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Testing {{ cookiecutter.generate_file }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
newline is CRLF | ||
newline is CRLF | ||
newline is CRLF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
newline is LF | ||
newline is LF |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"full_name": "Philippe Ombredanne", | ||
"year": "2015", | ||
"color": "blue", | ||
"letter": "D", | ||
"folder_name": "im_a.dir", | ||
"filename": "im_a.file", | ||
"test_name": "output_folder" | ||
} |
1 change: 1 addition & 0 deletions
1
tests/test-generate-files-line-end/{{cookiecutter.test_name}}/folder/in_folder.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The color is {{ cookiecutter.color }} and the letter is {{ cookiecutter.letter }}. |
3 changes: 3 additions & 0 deletions
3
tests/test-generate-files-line-end/{{cookiecutter.test_name}}/something.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Hi! | ||
My name is {{ cookiecutter.full_name }}. | ||
It is {{ cookiecutter.year }}. |
2 changes: 2 additions & 0 deletions
2
...-end/{{cookiecutter.test_name}}/{{cookiecutter.folder_name}}/{{cookiecutter.filename}}.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"""Sample file to be created through a cookiecutter run.""" | ||
print("This is the contents of {{ cookiecutter.filename }}.py.") |
3 changes: 3 additions & 0 deletions
3
tests/test-generate-files/input{{cookiecutter.food}}/simple-with-newline-crlf.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
newline is CRLF | ||
newline is CRLF | ||
newline is CRLF |
3 changes: 2 additions & 1 deletion
3
tests/test-generate-files/input{{cookiecutter.food}}/simple-with-newline.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
I eat {{ cookiecutter.food }} | ||
newline is LF | ||
newline is LF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.