From c1f7fc57bb4808d9046a50a7ba8fda09b0630de0 Mon Sep 17 00:00:00 2001 From: Silvio Fricke Date: Wed, 26 Jul 2017 09:39:26 +0200 Subject: [PATCH] add fallback way for annotation on gerrit service The account information [1][2] on gerrit has changed over time. The change add a fallback way when all optional fields are not set to use the non-optional fields `_account_id`. [1]: https://gerrit-documentation.storage.googleapis.com/Documentation/2.9/rest-api-accounts.html#account-info [2]: https://gerrit-documentation.storage.googleapis.com/Documentation/2.14/rest-api-accounts.html#account-info Signed-off-by: Silvio Fricke --- bugwarrior/services/gerrit.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bugwarrior/services/gerrit.py b/bugwarrior/services/gerrit.py index bfaf26233..58d1be37e 100644 --- a/bugwarrior/services/gerrit.py +++ b/bugwarrior/services/gerrit.py @@ -135,7 +135,12 @@ def build_url(self, change): def annotations(self, change): entries = [] for item in change['messages']: - username = item['author']['username'] + for key in ['name', 'username', 'email']: + if key in item['author']: + username = item['author'][key] + break + else: + username = item['author']['_account_id'] # Gerrit messages are really messy message = item['message']\ .lstrip('Patch Set ')\