mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Add unit test for mixed_line_ending
This commit is contained in:
parent
f477582ae6
commit
b1294b8614
2 changed files with 36 additions and 1 deletions
|
|
@ -74,7 +74,8 @@ def mixed_line_ending(argv=None):
|
|||
|
||||
if fix_option == MixedLineEndingOption.NO:
|
||||
logging.info('No conversion asked')
|
||||
pass
|
||||
|
||||
return 0
|
||||
elif fix_option == MixedLineEndingOption.AUTO:
|
||||
for filename in options['filenames']:
|
||||
detect_result = _detect_line_ending(filename)
|
||||
|
|
@ -90,12 +91,18 @@ def mixed_line_ending(argv=None):
|
|||
le_enum.str_print, le_enum.str_print)
|
||||
|
||||
_convert_line_ending(filename, le_enum.string)
|
||||
|
||||
return 1
|
||||
elif detect_result == MixedLineDetection.NOT_MIXED:
|
||||
logging.info('The file %s has no mixed line ending', filename)
|
||||
|
||||
return 0
|
||||
elif detect_result == MixedLineDetection.UNKNOWN:
|
||||
logging.info('Could not define most frequent line ending in '
|
||||
'file %s. File skiped.', filename)
|
||||
|
||||
return 0
|
||||
|
||||
# when a line ending character is forced with --fix option
|
||||
else:
|
||||
line_ending_enum = fix_option.line_ending_enum
|
||||
|
|
@ -105,6 +112,8 @@ def mixed_line_ending(argv=None):
|
|||
for filename in options['filenames']:
|
||||
_convert_line_ending(filename, line_ending_enum.string)
|
||||
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue