File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 61156ea714d18c48377ee15f1fa08a44990db2c1
2
+ refs/heads/master: 828afaa2fa4cc9e3e53bda0ae3073abfcfa151ca
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/python
2
2
3
- import sys , fileinput
3
+ import sys , fileinput , subprocess
4
4
5
5
err = 0
6
6
cols = 78
7
7
8
+ try :
9
+ result = subprocess .check_output ([ "git" , "config" , "core.autocrlf" ])
10
+ autocrlf = result .strip () == b"true"
11
+ except CalledProcessError :
12
+ autocrlf = False
13
+
8
14
def report_err (s ):
9
15
global err
10
16
print ("%s:%d: %s" % (fileinput .filename (), fileinput .filelineno (), s ))
@@ -14,10 +20,11 @@ def report_err(s):
14
20
if line .find ('\t ' ) != - 1 and fileinput .filename ().find ("Makefile" ) == - 1 :
15
21
report_err ("tab character" )
16
22
17
- if line .find ('\r ' ) != - 1 :
23
+ if not autocrlf and line .find ('\r ' ) != - 1 :
18
24
report_err ("CR character" )
19
25
20
- if len (line )- 1 > cols :
26
+ line_len = len (line )- 2 if autocrlf else len (line )- 1
27
+ if line_len > cols :
21
28
report_err ("line longer than %d chars" % cols )
22
29
23
30
You can’t perform that action at this time.
0 commit comments