mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-03 10:56:52 +00:00
Don't convert windows style \r\n to \n in file-contents-sorter
Instead preserve the original line endings. With the `--unique` flag identical lines with different line endings are collapsed to the first entry.
This commit is contained in:
parent
8ef58bed01
commit
7400b45161
2 changed files with 79 additions and 7 deletions
|
|
@ -17,6 +17,7 @@ from pre_commit_hooks.file_contents_sorter import PASS
|
|||
(b'missing_newline', [], FAIL, b'missing_newline\n'),
|
||||
(b'newline\nmissing', [], FAIL, b'missing\nnewline\n'),
|
||||
(b'missing\nnewline', [], FAIL, b'missing\nnewline\n'),
|
||||
(b'missing\r\nnewline', [], FAIL, b'missing\r\nnewline\r\n'),
|
||||
(b'alpha\nbeta\n', [], PASS, b'alpha\nbeta\n'),
|
||||
(b'beta\nalpha\n', [], FAIL, b'alpha\nbeta\n'),
|
||||
(b'C\nc\n', [], PASS, b'C\nc\n'),
|
||||
|
|
@ -67,6 +68,12 @@ from pre_commit_hooks.file_contents_sorter import PASS
|
|||
FAIL,
|
||||
b'Fie\nFoe\nfee\nfum\n',
|
||||
),
|
||||
(
|
||||
b'Fie\r\nFie\nFoe\nfee\nfee\r\nfum\n',
|
||||
['--unique'],
|
||||
FAIL,
|
||||
b'Fie\r\nFoe\nfee\nfum\n',
|
||||
),
|
||||
(
|
||||
b'fee\nFie\nFoe\nfum\n',
|
||||
['--unique', '--ignore-case'],
|
||||
|
|
@ -79,6 +86,24 @@ from pre_commit_hooks.file_contents_sorter import PASS
|
|||
FAIL,
|
||||
b'fee\nFie\nFoe\nfum\n',
|
||||
),
|
||||
(
|
||||
b'linefeed\r\ncarriage_return\r\n',
|
||||
[],
|
||||
FAIL,
|
||||
b'carriage_return\r\nlinefeed\r\n',
|
||||
),
|
||||
(
|
||||
b'carriage_return\r\nlinefeed\r\n',
|
||||
[],
|
||||
PASS,
|
||||
b'carriage_return\r\nlinefeed\r\n',
|
||||
),
|
||||
(
|
||||
b'a\na\r\na\r\na\na\r\na\n',
|
||||
[],
|
||||
PASS,
|
||||
b'a\na\r\na\r\na\na\r\na\n',
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_integration(input_s, argv, expected_retval, output, tmpdir):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue