From 72e2fbd725639339e094574bd07c03aa5b386835 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Wed, 27 Nov 2013 13:30:44 -0500 Subject: [PATCH] Allow specific files to be checked by lint-all. (imported from commit a17800e3ab079e95033243bc82446737dc456b68) --- tools/lint-all | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/lint-all b/tools/lint-all index e65cfd50b8..6fa0dc170e 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -35,12 +35,16 @@ api/setup.py """.split() -# Categorize by language all files known to Git +if args: + files = args +else: + # If no files are specified on the command line, use the entire git checkout + files = map(str.strip, subprocess.check_output(['git', 'ls-files']).split('\n')) -git_files = map(str.strip, subprocess.check_output(['git', 'ls-files']).split('\n')) +# Categorize by language all files we want to check by_lang = defaultdict(list) -for filepath in git_files: +for filepath in files: if (not filepath or not path.isfile(filepath) or (filepath in exclude_files) or any(filepath.startswith(d+'/') for d in exclude_trees)): @@ -111,6 +115,8 @@ logger = logging.getLogger() logger.setLevel(logging.WARNING) def check_pyflakes(): + if not by_lang['.py']: + return False failed = False pyflakes = subprocess.Popen(['pyflakes'] + by_lang['.py'], stdout = subprocess.PIPE, @@ -187,6 +193,8 @@ try: @lint def puppet(): + if not by_lang['.pp']: + return 0 result = subprocess.call(['puppet', 'parser', 'validate'] + by_lang['.pp']) return result