aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>2020-12-18 10:43:22 -0800
committerGitHub <noreply@github.com>2020-12-18 10:43:22 -0800
commitc2165341d2ccf09a50e239b3e2902b4c4426d088 (patch)
treeb28a00c289b2b71c688bffaf5e638956a85a499a
parent2a1194c9391af6a7d74e7645152969b067dab23c (diff)
downloadoss-fuzz-c2165341d2ccf09a50e239b3e2902b4c4426d088.tar.gz
[presubmit] Support option to run on all files (#4870)
-rwxr-xr-xinfra/presubmit.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/infra/presubmit.py b/infra/presubmit.py
index b85af5bef..3a616aca0 100755
--- a/infra/presubmit.py
+++ b/infra/presubmit.py
@@ -351,6 +351,13 @@ def run_tests():
return not result.failures and not result.errors
+def get_all_files():
+ """Returns a list of absolute paths of files in this repo."""
+ get_all_files_command = ['git', 'ls-files']
+ output = subprocess.check_output(get_all_files_command).decode().splitlines()
+ return [os.path.abspath(path) for path in output if os.path.isfile(path)]
+
+
def main():
"""Check changes on a branch for common issues before submitting."""
# Get program arguments.
@@ -358,30 +365,38 @@ def main():
parser.add_argument('command',
choices=['format', 'lint', 'license', 'infra-tests'],
nargs='?')
+ parser.add_argument('--all-files',
+ action='store_true',
+ help='Run presubmit check(s) on all files',
+ default=False)
args = parser.parse_args()
- changed_files = get_changed_files()
+ if args.all_files:
+ relevant_files = get_all_files()
+ else:
+ relevant_files = get_changed_files()
os.chdir(_SRC_ROOT)
# Do one specific check if the user asked for it.
if args.command == 'format':
- success = yapf(changed_files, False)
+ success = yapf(relevant_files, False)
return bool_to_returncode(success)
if args.command == 'lint':
- success = lint(changed_files)
+ success = lint(relevant_files)
return bool_to_returncode(success)
if args.command == 'license':
- success = check_license(changed_files)
+ success = check_license(relevant_files)
return bool_to_returncode(success)
if args.command == 'infra-tests':
- return bool_to_returncode(run_tests())
+ success = run_tests()
+ return bool_to_returncode(success)
# Do all the checks (but no tests).
- success = do_checks(changed_files)
+ success = do_checks(relevant_files)
return bool_to_returncode(success)