Remove bug assignee dependency on LP E-mail.
* jeepyb/cmd/update_bug.py(set_in_progress): Instead of querying Launchpad for E-mail addresses matching the change author, look in Gerrit to find an OpenID and look the user up with the getByOpenIDIdentifier call. Change-Id: Ifb457237cd02f5f3db4e95f26c87c08cf698de9a Reviewed-on: https://review.openstack.org/17488 Reviewed-by: Monty Taylor <mordred@inaugust.com> Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Approved: Jeremy Stanley <fungi@yuggoth.org> Reviewed-by: Jeremy Stanley <fungi@yuggoth.org> Tested-by: Jenkins
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
from launchpadlib.launchpad import Launchpad
|
from launchpadlib.launchpad import Launchpad
|
||||||
from launchpadlib.uris import LPNET_SERVICE_ROOT
|
from launchpadlib.uris import LPNET_SERVICE_ROOT
|
||||||
|
import jeepyb.gerritdb
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
import re
|
import re
|
||||||
@@ -55,15 +56,41 @@ Branch: %s\n''' % (change_url, git_url, submitter, branch)
|
|||||||
def set_in_progress(bugtask, launchpad, uploader, change_url):
|
def set_in_progress(bugtask, launchpad, uploader, change_url):
|
||||||
"""Set bug In progress with assignee being the uploader"""
|
"""Set bug In progress with assignee being the uploader"""
|
||||||
|
|
||||||
# Retrieve uploader from Launchpad. Use email as search key if
|
# Retrieve uploader from Launchpad by correlating Gerrit E-mail
|
||||||
# provided, and only set if there is a clear match.
|
# address to OpenID, and only set if there is a clear match.
|
||||||
try:
|
try:
|
||||||
searchkey = uploader[uploader.rindex("(") + 1:-1]
|
searchkey = uploader[uploader.rindex("(") + 1:-1]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
searchkey = uploader
|
searchkey = uploader
|
||||||
persons = launchpad.people.findPerson(text=searchkey)
|
|
||||||
if len(persons) == 1:
|
# The counterintuitive query is due to odd database schema choices
|
||||||
bugtask.assignee = persons[0]
|
# in Gerrit. For example, an account with a secondary E-mail
|
||||||
|
# address added looks like...
|
||||||
|
# select email_address,external_id from account_external_ids
|
||||||
|
# where account_id=1234;
|
||||||
|
# +-----------------+-----------------------------------------+
|
||||||
|
# | email_address | external_id |
|
||||||
|
# +-----------------+-----------------------------------------+
|
||||||
|
# | plugh@xyzzy.com | https://login.launchpad.net/+id/fR0bnU1 |
|
||||||
|
# | bar@foo.org | mailto:bar@foo.org |
|
||||||
|
# | NULL | username:quux |
|
||||||
|
# +-----------------+-----------------------------------------+
|
||||||
|
# ...thus we need a join on a secondary query to search against
|
||||||
|
# all the user's configured E-mail addresses.
|
||||||
|
#
|
||||||
|
query = """SELECT t.external_id FROM account_external_ids t
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT t.account_id FROM account_external_ids t
|
||||||
|
WHERE t.email_address = %s )
|
||||||
|
original ON t.account_id = original.account_id
|
||||||
|
AND t.external_id LIKE 'https://%%'"""
|
||||||
|
|
||||||
|
cursor = jeepyb.gerritdb.connect().cursor()
|
||||||
|
cursor.execute(query, searchkey)
|
||||||
|
data = cursor.fetchone()
|
||||||
|
if data:
|
||||||
|
bugtask.assignee = launchpad.people.getByOpenIDIdentifier(
|
||||||
|
identifier=data[0])
|
||||||
|
|
||||||
bugtask.status = "In Progress"
|
bugtask.status = "In Progress"
|
||||||
bugtask.lp_save()
|
bugtask.lp_save()
|
||||||
|
|||||||
Reference in New Issue
Block a user