summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-02-21 17:25:20 +0000
committerGerrit Code Review <review@openstack.org>2018-02-21 17:25:20 +0000
commitf32d742effb74d8e5f81673247411189aa7308e2 (patch)
treed1493d7683aa3c3229c92682d3639754f8b3ec20
parent981dfa50faf95f0248ca9490e05def3ab46a6309 (diff)
parent2240fc3450654fdb3a91e83a86c96d304d259943 (diff)
Merge "Add _get_username method to discover username"feature/limnoria
-rwxr-xr-xgerritbot/bot.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/gerritbot/bot.py b/gerritbot/bot.py
index fc38ac0..8a60c71 100755
--- a/gerritbot/bot.py
+++ b/gerritbot/bot.py
@@ -186,9 +186,18 @@ class Gerrit(threading.Thread):
186 # Delay before attempting again. 186 # Delay before attempting again.
187 time.sleep(1) 187 time.sleep(1)
188 188
189 @staticmethod
190 def _get_username(patchset):
191 # Try to find username
192 for key in ('name', 'username', 'email'):
193 username = patchset['uploader'].get(key)
194 if username:
195 return username
196 return "UNKNOWN USER"
197
189 def patchset_created(self, channel, data): 198 def patchset_created(self, channel, data):
190 msg = '%s proposed %s %s: %s %s' % ( 199 msg = '%s proposed %s %s: %s %s' % (
191 data['patchSet']['uploader']['name'], 200 self._get_username(data['patchSet']),
192 data['change']['project'], 201 data['change']['project'],
193 data['change']['branch'], 202 data['change']['branch'],
194 data['change']['subject'], 203 data['change']['subject'],