mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-30 18:26:53 +00:00
In mixed-line-endings, move check/print to main() as suggested by asottile (PR 341)
This commit is contained in:
parent
f3c65bcd20
commit
59ed512020
1 changed files with 7 additions and 8 deletions
|
|
@ -37,15 +37,9 @@ def fix_filename(filename, fix):
|
|||
# Some amount of mixed line endings
|
||||
mixed = sum(bool(x) for x in counts.values()) > 1
|
||||
|
||||
if fix == 'no':
|
||||
if mixed:
|
||||
# Not fixing, just report problematic file
|
||||
print('Mixed line endings: {filename}'.format(filename=filename))
|
||||
if fix == 'no' or (fix == 'auto' and not mixed):
|
||||
return mixed
|
||||
|
||||
if fix == 'auto' and not mixed:
|
||||
return False
|
||||
|
||||
if fix == 'auto':
|
||||
max_ending = LF
|
||||
max_lines = 0
|
||||
|
|
@ -82,7 +76,12 @@ def main(argv=None):
|
|||
|
||||
retv = 0
|
||||
for filename in args.filenames:
|
||||
retv |= fix_filename(filename, args.fix)
|
||||
if fix_filename(filename, args.fix):
|
||||
if args.fix == 'no':
|
||||
print('{}: mixed line endings'.format(filename))
|
||||
else:
|
||||
print('{}: fixed mixed line endings'.format(filename))
|
||||
retv = 1
|
||||
return retv
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue