Improve presubmit check messaging

Also add oneline status on gclient gitmodules.

R=jojwang@google.com

Change-Id: I05c9f856ce6fd1c3ebf1dc7da672d25196a4cb67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4771975
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
changes/75/4771975/2
Josip Sokcevic 2 years ago committed by LUCI CQ
parent e0790f1428
commit de6bc6620a

@ -2729,6 +2729,8 @@ def CMDgitmodules(parser, args):
f.write(f'[submodule "{path}"]\n\tpath = {path}\n\turl = {url}\n') f.write(f'[submodule "{path}"]\n\tpath = {path}\n\turl = {url}\n')
if 'condition' in dep: if 'condition' in dep:
f.write(f'\tgclient-condition = {dep["condition"]}\n') f.write(f'\tgclient-condition = {dep["condition"]}\n')
print('.gitmodules and gitlinks updated. Please check git diff and '
'commit changes.')
@metrics.collector.collect_metrics('gclient flatten') @metrics.collector.collect_metrics('gclient flatten')

@ -1518,13 +1518,16 @@ def PanProjectChecks(input_api, output_api,
results.extend( results.extend(
input_api.canned_checks.CheckCorpLinksInDescription( input_api.canned_checks.CheckCorpLinksInDescription(
input_api, output_api)) input_api, output_api))
if input_api.change.scm == 'git':
snapshot("checking for commit objects in tree")
results.extend(input_api.canned_checks.CheckForCommitObjects(
input_api, output_api))
snapshot("checking do not submit in files") snapshot("checking do not submit in files")
results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles(
input_api, output_api)) input_api, output_api))
if global_checks:
if input_api.change.scm == 'git':
snapshot("checking for commit objects in tree")
results.extend(
input_api.canned_checks.CheckForCommitObjects(input_api, output_api))
snapshot("done") snapshot("done")
return results return results
@ -1769,19 +1772,23 @@ def CheckForCommitObjects(input_api, output_api):
] ]
mismatch_entries = [] mismatch_entries = []
deps_msg = ""
for commit_tree_entry in commit_tree_entries: for commit_tree_entry in commit_tree_entries:
# Search for commit hashes in DEPS file - they must be present # Search for commit hashes in DEPS file - they must be present
if commit_tree_entry[2] not in deps_content: if commit_tree_entry[2] not in deps_content:
mismatch_entries.append(commit_tree_entry[3]) mismatch_entries.append(commit_tree_entry[3])
deps_msg += f"\n {commit_tree_entry[3]} -> {commit_tree_entry[2]}"
if mismatch_entries: if mismatch_entries:
return [ return [
output_api.PresubmitError( output_api.PresubmitError(
'DEPS file indicates git submodule migration is in progress,\n' 'DEPS file indicates git submodule migration is in progress,\n'
'but the commit objects do not match DEPS entries.\n' 'but the commit objects do not match DEPS entries.\n\n'
'Update the following commit objects with:\n' 'To reset all git submodule git entries to match DEPS, run\n'
'`git update-index --add --cacheinfo 160000,<commit_rev>,<path>`' 'the following command in the root of this repository:\n'
'\n' ' gclient gitmodules'
'or DEPS entries:\n', mismatch_entries) '\n\n'
'If git submodule changes are correct, update the following DEPS '
'entries to: ' + deps_msg)
] ]
return [] return []

Loading…
Cancel
Save