summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPhillip Sz <phillip.szelat@gmail.com>2016-05-26 21:30:02 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-05-27 06:19:46 +0000
commit02b666c4770b4a4c7a5bb5dba9c3738515921e00 (patch)
tree44bdcec35f991279ca21625c5055a338de16e73e /bin
parent4aca087c7cb9ffe831b277a62ad3e993c3b2ca58 (diff)
find-german-comments: enable scanning subdirs
This makes it possible to scan sub directories, when you give them as arguments to the script. Also update the directory_whitelist. Change-Id: I0a8468348fffe0814905d6f5602fad3f8d6b69e3 Reviewed-on: https://gerrit.libreoffice.org/25523 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/find-german-comments48
1 files changed, 34 insertions, 14 deletions
diff --git a/bin/find-german-comments b/bin/find-german-comments
index 86dfe547247f..0a9c0f07f3d2 100755
--- a/bin/find-german-comments
+++ b/bin/find-german-comments
@@ -224,12 +224,27 @@ class Parser:
"""
checks each _tracked_ file in a directory recursively
"""
- sock = os.popen(r"git ls-files '%s' |egrep '\.(c|cc|cpp|cxx|h|hxx|mm)$'" % directory)
+ globalscan = False
+ if re.match(r'.*/core$', os.getcwd()) and directory == '.':
+ globalscan = True
+
+ # Change into the given dir, so "git ls-tree" does work.
+ # If we want to scan the current dir, we must not do so as we are already there.
+ if not globalscan and directory != '.':
+ currentdir = os.getcwd()
+ os.chdir(currentdir.split("core",1)[0] + "core/")
+ os.chdir(directory)
+
+ sock = os.popen(r"git ls-tree -r HEAD --name-only |egrep '\.(c|cc|cpp|cxx|h|hxx|mm)$'")
lines = sock.readlines()
sock.close()
# Helps to speedup a global scan
directory_whitelist = {
+ "ure" : 1,
+ "ios" : 1,
+ "bean" : 1,
+ "apple_remote" : 1,
"UnoControls" : 1,
"accessibility" : 1,
"android" : 1,
@@ -351,26 +366,31 @@ class Parser:
"xmlscript" : 1,
}
- if directory is '.':
- sys.stderr.write("Overriding the white-list for the current directory - pass an absolute path to the top-level for faster global white-list searches.\n")
+ if globalscan:
+ print("Scanning all files globally:")
+ elif directory == '.':
+ print("Scanning all files in our current directory:")
+ else:
+ print("Scanning all files in", directory + ":")
num_checked = 0
for path in lines:
baseDir = self.first_elem(path)
-
- # Support searching within sub directories
- if directory is '.':
- self.check_file(path.strip())
- elif not baseDir in directory_whitelist:
- sys.stderr.write ("\n - Error: Missing path %s -\n\n" % baseDir)
- sys.exit(1)
- elif directory_whitelist[baseDir] is 0:
+ # If we have an globalscan use the whitelist.
+ if globalscan:
+ if not baseDir in directory_whitelist:
+ sys.stderr.write ("\n - Error: Missing path %s -\n\n" % baseDir)
+ sys.exit(1)
+ elif directory_whitelist[baseDir] is 0:
+ self.check_file(path.strip())
+ num_checked = num_checked + 1
+ elif directory_whitelist[baseDir] is 1:
+ sys.stderr.write ("Skipping whitelisted directory %s\n" % baseDir)
+ directory_whitelist[baseDir] = 2
+ elif not globalscan:
self.check_file(path.strip())
num_checked = num_checked + 1
- elif directory_whitelist[baseDir] is 1:
- sys.stderr.write ("Skipping whitelisted directory %s\n" % baseDir)
- directory_whitelist[baseDir] = 2
sys.stderr.write ("Scanned %s files\n" % num_checked)