Handle newer gerrit in update blueprint script

Newer gerrit provides the project name and the branch the change is
proposed against as well as the change id itself in the --change
argument to patchset created hooks. This is a behavior change that we
have to handle as old gerrit passed only the change id.

We do this by going to the old behavior of the script by splitting off
the change id from the new string and using only that. Note that this
may not be strictly correct as multiple changes can share a change id
(likely why gerrit made this change in the first place). We can worry
about properly correct behavior in future updates.

Change-Id: Idef56e98ed6c753a58b766024295b2f5147e3aea
This commit is contained in:
Clark Boylan 2017-09-23 12:21:13 -07:00
parent 8b50df9ead
commit 5b68b2227f
1 changed files with 7 additions and 1 deletions

View File

@ -114,9 +114,15 @@ def find_specs(launchpad, dbconn, args):
args.commit + '^1..' + args.commit],
stdout=subprocess.PIPE).communicate()[0]
change = args.change
if '~' in change:
# Newer gerrit provides the change argument in this format:
# gtest-org%2Fgtest~master~I117f34aaa4253e0b82b98de9077f7188d55c3f33
# So we need to split off the changeid if there is other data in there.
change = change.rsplit('~', 1)[1]
cur = dbconn.cursor()
cur.execute("select subject, topic from changes where change_key=%s",
args.change)
change)
subject, topic = cur.fetchone()
specs = set([m.group(2) for m in SPEC_RE.finditer(git_log)])