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 <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Andrii Shyshkalov <tandrii@google.com>
diff --git a/git_cl.py b/git_cl.py
index ff391a2..60230cb 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -102,7 +102,6 @@
 '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 @@
 
     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: