File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed 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
+ config_proc = subprocess .Popen ([ "git" , "config" , "core.autocrlf" ],
9
+ stdout = subprocess .PIPE )
10
+ result = config_proc .communicate ()[0 ]
11
+ autocrlf = result .strip () == b"true" if result is not None else False
12
+
8
13
def report_err (s ):
9
14
global err
10
15
print ("%s:%d: %s" % (fileinput .filename (), fileinput .filelineno (), s ))
@@ -14,10 +19,11 @@ def report_err(s):
14
19
if line .find ('\t ' ) != - 1 and fileinput .filename ().find ("Makefile" ) == - 1 :
15
20
report_err ("tab character" )
16
21
17
- if line .find ('\r ' ) != - 1 :
22
+ if not autocrlf and line .find ('\r ' ) != - 1 :
18
23
report_err ("CR character" )
19
24
20
- if len (line )- 1 > cols :
25
+ line_len = len (line )- 2 if autocrlf else len (line )- 1
26
+ if line_len > cols :
21
27
report_err ("line longer than %d chars" % cols )
22
28
23
29
You can’t perform that action at this time.
0 commit comments