From de6bc6620a76e2f749449d883960becd2e71e231 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Thu, 10 Aug 2023 22:27:23 +0000 Subject: [PATCH] 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 Auto-Submit: Josip Sokcevic Commit-Queue: Joanna Wang Commit-Queue: Josip Sokcevic --- gclient.py | 2 ++ presubmit_canned_checks.py | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/gclient.py b/gclient.py index ce1a489716..5dffe75ba0 100755 --- a/gclient.py +++ b/gclient.py @@ -2729,6 +2729,8 @@ def CMDgitmodules(parser, args): f.write(f'[submodule "{path}"]\n\tpath = {path}\n\turl = {url}\n') if 'condition' in dep: 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') diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 3bfa0d83d2..b038e13d8e 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -1518,13 +1518,16 @@ def PanProjectChecks(input_api, output_api, results.extend( input_api.canned_checks.CheckCorpLinksInDescription( 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") results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( 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") return results @@ -1769,19 +1772,23 @@ def CheckForCommitObjects(input_api, output_api): ] mismatch_entries = [] + deps_msg = "" for commit_tree_entry in commit_tree_entries: # Search for commit hashes in DEPS file - they must be present if commit_tree_entry[2] not in deps_content: mismatch_entries.append(commit_tree_entry[3]) + deps_msg += f"\n {commit_tree_entry[3]} -> {commit_tree_entry[2]}" if mismatch_entries: return [ output_api.PresubmitError( 'DEPS file indicates git submodule migration is in progress,\n' - 'but the commit objects do not match DEPS entries.\n' - 'Update the following commit objects with:\n' - '`git update-index --add --cacheinfo 160000,,`' - '\n' - 'or DEPS entries:\n', mismatch_entries) + 'but the commit objects do not match DEPS entries.\n\n' + 'To reset all git submodule git entries to match DEPS, run\n' + 'the following command in the root of this repository:\n' + ' gclient gitmodules' + '\n\n' + 'If git submodule changes are correct, update the following DEPS ' + 'entries to: ' + deps_msg) ] return []