Use full gerrit changeid in HTTP report

We need to specify the project and branch to make a fully unique
change id when reporting to Gerrit over HTTP.

Change-Id: I23362c029beb84c0ce529238e5280280d9b6a75a
This commit is contained in:
James E. Blair 2018-08-07 09:04:01 -07:00
parent 91c775a1aa
commit 1a0a9614d5
2 changed files with 9 additions and 8 deletions

View File

@ -531,8 +531,9 @@ class GerritWebServer(object):
self.end_headers()
def _get_change(self, change_id):
project, branch, change = change_id.split('~')
for c in fake_gerrit.changes.values():
if c.data['id'] == change_id:
if c.data['id'] == change:
return c
def review(self, change_id, revision, data):

View File

@ -24,6 +24,7 @@ import logging
import pprint
import shlex
import queue
import urllib.parse
import voluptuous as v
import requests
@ -817,15 +818,14 @@ class GerritConnection(BaseConnection):
data['labels'] = labels
if file_comments:
data['comments'] = file_comments
# { path: [
# {line=42, message='foobar'},
# {line=40, message='baz'},
# ]
# }
changeid = "%s~%s~%s" % (
urllib.parse.quote(str(change.project), safe=''),
urllib.parse.quote(str(change.branch), safe=''),
change.id)
for x in range(1, 4):
try:
self.post('changes/%s/revisions/%s/review' %
(change.id, change.commit),
(changeid, change.commit),
data)
break
except Exception:
@ -834,7 +834,7 @@ class GerritConnection(BaseConnection):
time.sleep(x * 10)
if change.is_current_patchset and submit:
try:
self.post('changes/%s/submit' % (change.id,), {})
self.post('changes/%s/submit' % (changeid,), {})
except Exception:
self.log.exception(
"Error submitting data to gerrit, attempt %s", x)