File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
- #!/usr/bin/python
1
+ #!/usr/bin/python2.5
2
2
3
- import sys , fileinput
3
+ import sys , fileinput , subprocess
4
4
5
5
err = 0
6
6
cols = 78
7
7
8
+ # Be careful to support Python 2.4, 2.6, and 3.x here!
9
+ config_proc = subprocess .Popen ([ "git" , "config" , "core.autocrlf" ],
10
+ stdout = subprocess .PIPE )
11
+ result = config_proc .communicate ()[0 ]
12
+
13
+ true = "true" .encode ('utf8' )
14
+ autocrlf = result .strip () == true if result is not None else False
15
+
8
16
def report_err (s ):
9
17
global err
10
18
print ("%s:%d: %s" % (fileinput .filename (), fileinput .filelineno (), s ))
@@ -14,10 +22,11 @@ def report_err(s):
14
22
if line .find ('\t ' ) != - 1 and fileinput .filename ().find ("Makefile" ) == - 1 :
15
23
report_err ("tab character" )
16
24
17
- if line .find ('\r ' ) != - 1 :
25
+ if not autocrlf and line .find ('\r ' ) != - 1 :
18
26
report_err ("CR character" )
19
27
20
- if len (line )- 1 > cols :
28
+ line_len = len (line )- 2 if autocrlf else len (line )- 1
29
+ if line_len > cols :
21
30
report_err ("line longer than %d chars" % cols )
22
31
23
32
You can’t perform that action at this time.
0 commit comments