mirror of https://github.com/google/oss-fuzz.git
[presubmit] Support option to run on all files (#4870)
This commit is contained in:
parent
2a1194c939
commit
c2165341d2
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue