From 8aa9d62e8ecce56cd1054bd8c2dd72ba02c7bb04 Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Tue, 10 Mar 2020 19:15:35 +0000 Subject: [PATCH] git cl: better detection of messages from CQ. CQ added support to project-scoped accounts instead of previously hardcoded commit-bot@ for working with Gerrit. R=ehmaldonado Test: `git cl status` on this very CL :) Bug: 911811 Change-Id: I8f48a7bdc9dad9a5b71d266ccf7e9a493aa94aa9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2095986 Reviewed-by: Edward Lesmes Commit-Queue: Edward Lesmes Auto-Submit: Andrii Shyshkalov --- git_cl.py | 10 ++++------ tests/git_cl_test.py | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/git_cl.py b/git_cl.py index ff391a236..60230cb19 100755 --- a/git_cl.py +++ b/git_cl.py @@ -102,7 +102,6 @@ TRACES_README_FORMAT = ( 'Execution time: %(execution_time)s\n' 'Exit code: %(exit_code)s\n') + TRACES_MESSAGE -COMMIT_BOT_EMAIL = 'commit-bot@chromium.org' POSTUPSTREAM_HOOK = '.git/hooks/post-cl-land' DESCRIPTION_BACKUP_FILE = '.git_cl_description_backup' REFS_THAT_ALIAS_TO_OTHER_REFS = { @@ -1799,13 +1798,12 @@ class Changelist(object): owner = data['owner'].get('_account_id') messages = sorted(data.get('messages', []), key=lambda m: m.get('date')) - last_message_author = messages.pop().get('author', {}) - while last_message_author: - if last_message_author.get('email') == COMMIT_BOT_EMAIL: + while messages: + m = messages.pop() + if m.get('tag', '').startswith('autogenerated:cq:'): # Ignore replies from CQ. - last_message_author = messages.pop().get('author', {}) continue - if last_message_author.get('_account_id') == owner: + if m.get('author', {}).get('_account_id') == owner: # Most recent message was by owner. return 'waiting' else: diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 435e57dd9..85ab7243b 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -2462,8 +2462,8 @@ class TestGitCl(unittest.TestCase): u'_revision_number': 1, u'author': { u'_account_id': 1111084, - u'email': u'commit-bot@chromium.org', - u'name': u'Commit Bot' + u'email': u'could-be-anything@example.com', + u'name': u'LUCI CQ' }, u'date': u'2017-03-15 20:08:45.000000000', u'id': u'f5a6c25ecbd3b3b54a43ae418ed97eff046dc50b',