summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-10-24 21:06:07 (GMT)
committerGerrit Code Review <gerrit@localhost.localdomain>2012-10-26 12:11:15 (GMT)
commite1fc03a2454767e5d8f9abe8ca7746b1e3dcfbf9 (patch)
treeefa2a5b960d8f51713c4750430c2d97354374db4 /BuildTools/CheckTabs.py
parent698d56b68533760931ea6e1509fea73cdcf35b67 (diff)
downloadswift-e1fc03a2454767e5d8f9abe8ca7746b1e3dcfbf9.zip
swift-e1fc03a2454767e5d8f9abe8ca7746b1e3dcfbf9.tar.bz2
Only check tabs & copyright of committed files.
Change-Id: Iba37ecbf03bab9e23a1ee9c72b39ee4266ec4032
Diffstat (limited to 'BuildTools/CheckTabs.py')
-rwxr-xr-xBuildTools/CheckTabs.py60
1 files changed, 25 insertions, 35 deletions
diff --git a/BuildTools/CheckTabs.py b/BuildTools/CheckTabs.py
index c685fc4..e007a68 100755
--- a/BuildTools/CheckTabs.py
+++ b/BuildTools/CheckTabs.py
@@ -4,38 +4,28 @@ import os, sys
foundExpandedTabs = False
-for (path, dirs, files) in os.walk(".") :
- if not "3rdParty" in path and not ".sconf" in path and not ".framework" in path and not path.startswith("build") :
- for filename in [os.path.join(path, file) for file in files if (file.endswith(".cpp") or file.endswith(".h")) and not "ui_" in file and not "moc_" in file and not "qrc_" in file] :
- file = open(filename, "r")
- contents = []
- contentsChanged = False
- for line in file.readlines() :
- newline = ""
- previousChar = None
- pastInitialSpace = False
- for char in line :
- if not pastInitialSpace :
- if char == ' ' and previousChar == ' ' :
- contentsChanged = True
- previousChar = '\t'
- continue
- pastInitialSpace = (char != ' ')
- if previousChar :
- newline += previousChar
- previousChar = char
- if previousChar :
- newline += previousChar
- contents.append(newline)
- file.close()
- if contentsChanged :
- if len(sys.argv) > 1 and sys.argv[1] == "--fix" :
- print("Fixing tabs in " + filename)
- file = open(filename, "w")
- file.write(''.join(contents))
- file.close()
- else :
- foundExpandedTabs = True
- print(filename + " contains expanded tabs")
-
-sys.exit(foundExpandedTabs)
+filename = sys.argv[1]
+if (filename.endswith(".cpp") or filename.endswith(".h")) and not "3rdParty" in filename :
+ file = open(filename, "r")
+ contents = []
+ contentsChanged = False
+ for line in file.readlines() :
+ newline = ""
+ previousChar = None
+ pastInitialSpace = False
+ for char in line :
+ if not pastInitialSpace :
+ if char == ' ' and previousChar == ' ' :
+ contentsChanged = True
+ previousChar = '\t'
+ continue
+ pastInitialSpace = (char != ' ')
+ if previousChar :
+ newline += previousChar
+ previousChar = char
+ if previousChar :
+ newline += previousChar
+ contents.append(newline)
+ file.close()
+ if contentsChanged :
+ sys.exit(-1)