Skip to content

Commit 59ed512

Browse files
committed
In mixed-line-endings, move check/print to main() as suggested by asottile (PR 341)
1 parent f3c65bc commit 59ed512

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pre_commit_hooks/mixed_line_ending.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,9 @@ def fix_filename(filename, fix):
3737
# Some amount of mixed line endings
3838
mixed = sum(bool(x) for x in counts.values()) > 1
3939

40-
if fix == 'no':
41-
if mixed:
42-
# Not fixing, just report problematic file
43-
print('Mixed line endings: {filename}'.format(filename=filename))
40+
if fix == 'no' or (fix == 'auto' and not mixed):
4441
return mixed
4542

46-
if fix == 'auto' and not mixed:
47-
return False
48-
4943
if fix == 'auto':
5044
max_ending = LF
5145
max_lines = 0
@@ -82,7 +76,12 @@ def main(argv=None):
8276

8377
retv = 0
8478
for filename in args.filenames:
85-
retv |= fix_filename(filename, args.fix)
79+
if fix_filename(filename, args.fix):
80+
if args.fix == 'no':
81+
print('{}: mixed line endings'.format(filename))
82+
else:
83+
print('{}: fixed mixed line endings'.format(filename))
84+
retv = 1
8685
return retv
8786

8887

0 commit comments

Comments
 (0)