Merge "Let the test mapping updater handle newly-added files."

This commit is contained in:
Joel Galenson
2021-08-30 19:47:01 +00:00
committed by Gerrit Code Review

View File

@@ -278,13 +278,17 @@ def main():
test_mapping = TestMapping(env, bazel, path) test_mapping = TestMapping(env, bazel, path)
test_mapping.create() test_mapping.create()
changed = (subprocess.call(['git', 'diff', '--quiet']) == 1) changed = (subprocess.call(['git', 'diff', '--quiet']) == 1)
if changed and args.branch_and_commit: untracked = (os.path.isfile('TEST_MAPPING') and
(subprocess.run(['git', 'ls-files', '--error-unmatch', 'TEST_MAPPING'],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL).returncode == 1))
if args.branch_and_commit and (changed or untracked):
subprocess.check_output(['repo', 'start', subprocess.check_output(['repo', 'start',
'tmp_auto_test_mapping', '.']) 'tmp_auto_test_mapping', '.'])
subprocess.check_output(['git', 'add', 'TEST_MAPPING']) subprocess.check_output(['git', 'add', 'TEST_MAPPING'])
subprocess.check_output(['git', 'commit', '-m', subprocess.check_output(['git', 'commit', '-m',
'Update TEST_MAPPING\n\nTest: None']) 'Update TEST_MAPPING\n\nTest: None'])
if changed and args.push_change: if args.push_change and (changed or untracked):
date = datetime.today().strftime('%m-%d') date = datetime.today().strftime('%m-%d')
subprocess.check_output(['git', 'push', 'aosp', 'HEAD:refs/for/master', subprocess.check_output(['git', 'push', 'aosp', 'HEAD:refs/for/master',
'-o', 'topic=test-mapping-%s' % date]) '-o', 'topic=test-mapping-%s' % date])