Merge "Fixed review control sustem polling"
This commit is contained in:
commit
23a26b8be8
@ -81,6 +81,7 @@
|
|||||||
],
|
],
|
||||||
"uri": "git://github.com/openstack/glance.git",
|
"uri": "git://github.com/openstack/glance.git",
|
||||||
"module": "glance",
|
"module": "glance",
|
||||||
|
"organization": "openstack",
|
||||||
"project_type": "openstack"
|
"project_type": "openstack"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -88,12 +89,14 @@
|
|||||||
"module": "python-glanceclient",
|
"module": "python-glanceclient",
|
||||||
"project_group": "core",
|
"project_group": "core",
|
||||||
"project_type": "openstack",
|
"project_type": "openstack",
|
||||||
|
"organization": "openstack",
|
||||||
"uri": "git://github.com/openstack/python-glanceclient.git"
|
"uri": "git://github.com/openstack/python-glanceclient.git"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"branches": ["master"],
|
"branches": ["master"],
|
||||||
"module": "stackalytics",
|
"module": "stackalytics",
|
||||||
"project_type": "stackforge",
|
"project_type": "stackforge",
|
||||||
|
"organization": "stackforge",
|
||||||
"uri": "git://github.com/stackforge/stackalytics.git"
|
"uri": "git://github.com/stackforge/stackalytics.git"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -71,6 +71,7 @@ def _retrieve_project_list(runtime_storage_inst, project_sources):
|
|||||||
r = {
|
r = {
|
||||||
'branches': ['master'],
|
'branches': ['master'],
|
||||||
'module': repo_name,
|
'module': repo_name,
|
||||||
|
'organization': organization,
|
||||||
'project_type': project_source['project_type'],
|
'project_type': project_source['project_type'],
|
||||||
'project_group': project_source['project_group'],
|
'project_group': project_source['project_group'],
|
||||||
'uri': repo_uri,
|
'uri': repo_uri,
|
||||||
|
@ -75,13 +75,13 @@ class Gerrit(Rcs):
|
|||||||
username=self.username)
|
username=self.username)
|
||||||
LOG.debug('Successfully connected to Gerrit')
|
LOG.debug('Successfully connected to Gerrit')
|
||||||
|
|
||||||
def _get_cmd(self, project_organization, module, branch, sort_key,
|
def _get_cmd(self, project_organization, module, branch, sort_key=None,
|
||||||
is_open):
|
is_open=False, limit=PAGE_LIMIT):
|
||||||
cmd = ('gerrit query --all-approvals --patch-sets --format JSON '
|
cmd = ('gerrit query --all-approvals --patch-sets --format JSON '
|
||||||
'project:\'%(ogn)s/%(module)s\' branch:%(branch)s '
|
'project:\'%(ogn)s/%(module)s\' branch:%(branch)s '
|
||||||
'limit:%(limit)s' %
|
'limit:%(limit)s' %
|
||||||
{'ogn': project_organization, 'module': module,
|
{'ogn': project_organization, 'module': module,
|
||||||
'branch': branch, 'limit': PAGE_LIMIT})
|
'branch': branch, 'limit': limit})
|
||||||
if is_open:
|
if is_open:
|
||||||
cmd += ' is:open'
|
cmd += ' is:open'
|
||||||
if sort_key:
|
if sort_key:
|
||||||
@ -104,7 +104,7 @@ class Gerrit(Rcs):
|
|||||||
|
|
||||||
if 'sortKey' in review:
|
if 'sortKey' in review:
|
||||||
sort_key = int(review['sortKey'], 16)
|
sort_key = int(review['sortKey'], 16)
|
||||||
if sort_key == last_id:
|
if sort_key <= last_id:
|
||||||
proceed = False
|
proceed = False
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -116,41 +116,34 @@ class Gerrit(Rcs):
|
|||||||
break
|
break
|
||||||
|
|
||||||
def log(self, branch, last_id):
|
def log(self, branch, last_id):
|
||||||
match = re.search(r'([^\/]+)/([^\/]+)\.git$', self.repo['uri'])
|
|
||||||
if not match:
|
|
||||||
LOG.error('Invalid repo uri: %s', self.repo['uri'])
|
|
||||||
project_organization = match.group(1)
|
|
||||||
module = match.group(2)
|
|
||||||
|
|
||||||
self._connect()
|
self._connect()
|
||||||
|
|
||||||
# poll new reviews from the top down to last_id
|
# poll new reviews from the top down to last_id
|
||||||
LOG.debug('Poll new reviews')
|
LOG.debug('Poll new reviews for module: %s', self.repo['module'])
|
||||||
for review in self._poll_reviews(project_organization, module, branch,
|
for review in self._poll_reviews(self.repo['organization'],
|
||||||
|
self.repo['module'], branch,
|
||||||
last_id=last_id):
|
last_id=last_id):
|
||||||
yield review
|
yield review
|
||||||
|
|
||||||
# poll open reviews from last_id down to bottom
|
# poll open reviews from last_id down to bottom
|
||||||
LOG.debug('Poll open reviews')
|
LOG.debug('Poll open reviews for module: %s', self.repo['module'])
|
||||||
start_id = None
|
start_id = None
|
||||||
if last_id:
|
if last_id:
|
||||||
start_id = last_id + 1 # include the last review into query
|
start_id = last_id + 1 # include the last review into query
|
||||||
for review in self._poll_reviews(project_organization, module, branch,
|
for review in self._poll_reviews(self.repo['organization'],
|
||||||
|
self.repo['module'], branch,
|
||||||
start_id=start_id, is_open=True):
|
start_id=start_id, is_open=True):
|
||||||
yield review
|
yield review
|
||||||
|
|
||||||
self.client.close()
|
self.client.close()
|
||||||
|
|
||||||
def get_last_id(self, branch):
|
def get_last_id(self, branch):
|
||||||
module = self.repo['module']
|
|
||||||
LOG.debug('Get last id for module %s', module)
|
|
||||||
|
|
||||||
self._connect()
|
self._connect()
|
||||||
|
LOG.debug('Get last id for module: %s', self.repo['module'])
|
||||||
|
|
||||||
cmd = ('gerrit query --all-approvals --patch-sets --format JSON '
|
cmd = self._get_cmd(self.repo['organization'], self.repo['module'],
|
||||||
'%(module)s branch:%(branch)s limit:1' %
|
branch, limit=1)
|
||||||
{'module': module, 'branch': branch})
|
LOG.debug('Executing command: %s', cmd)
|
||||||
|
|
||||||
stdin, stdout, stderr = self.client.exec_command(cmd)
|
stdin, stdout, stderr = self.client.exec_command(cmd)
|
||||||
last_id = None
|
last_id = None
|
||||||
for line in stdout:
|
for line in stdout:
|
||||||
@ -161,7 +154,8 @@ class Gerrit(Rcs):
|
|||||||
|
|
||||||
self.client.close()
|
self.client.close()
|
||||||
|
|
||||||
LOG.debug('Last id for module %s is %s', module, last_id)
|
LOG.debug('Module %(module)s last id is %(id)s',
|
||||||
|
{'module': self.repo['module'], 'id': last_id})
|
||||||
return last_id
|
return last_id
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ GIT_LOG_PATTERN = re.compile(''.join([(r[0] + ':(.*?)\n')
|
|||||||
MESSAGE_PATTERNS = {
|
MESSAGE_PATTERNS = {
|
||||||
'bug_id': re.compile(r'bug[\s#:]*(?P<id>\d+)', re.IGNORECASE),
|
'bug_id': re.compile(r'bug[\s#:]*(?P<id>\d+)', re.IGNORECASE),
|
||||||
'blueprint_id': re.compile(r'\b(?:blueprint|bp)\b[ \t]*[#:]?[ \t]*'
|
'blueprint_id': re.compile(r'\b(?:blueprint|bp)\b[ \t]*[#:]?[ \t]*'
|
||||||
r'(?P<id>\S+)', re.IGNORECASE),
|
r'(?P<id>[a-z0-9-]+)', re.IGNORECASE),
|
||||||
'change_id': re.compile('Change-Id: (?P<id>I[0-9a-f]{40})', re.IGNORECASE),
|
'change_id': re.compile('Change-Id: (?P<id>I[0-9a-f]{40})', re.IGNORECASE),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ date:1369119386
|
|||||||
author_name:Akihiro MOTOKI
|
author_name:Akihiro MOTOKI
|
||||||
author_email:motoki@da.jp.nec.com
|
author_email:motoki@da.jp.nec.com
|
||||||
subject:Remove class-based import in the code repo
|
subject:Remove class-based import in the code repo
|
||||||
message:Fixes bug 1167901
|
message:Fixes bug 1167901.
|
||||||
|
|
||||||
This commit also removes backslashes for line break.
|
This commit also removes backslashes for line break.
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ date:1369831203
|
|||||||
author_name:John Doe
|
author_name:John Doe
|
||||||
author_email:john.doe@dreamhost.com
|
author_email:john.doe@dreamhost.com
|
||||||
subject:add readme for 2.2.2
|
subject:add readme for 2.2.2
|
||||||
message: bp fix-me
|
message: implements blueprint fix-me.
|
||||||
Change-Id: Id32a4a72ec1d13992b306c4a38e73605758e26c7
|
Change-Id: Id32a4a72ec1d13992b306c4a38e73605758e26c7
|
||||||
|
|
||||||
diff_stat:
|
diff_stat:
|
||||||
@ -122,6 +122,8 @@ diff_stat:
|
|||||||
self.assertEquals(0, commits[3]['files_changed'])
|
self.assertEquals(0, commits[3]['files_changed'])
|
||||||
self.assertEquals(0, commits[3]['lines_added'])
|
self.assertEquals(0, commits[3]['lines_added'])
|
||||||
self.assertEquals(0, commits[3]['lines_deleted'])
|
self.assertEquals(0, commits[3]['lines_deleted'])
|
||||||
|
self.assertEquals(set(['fix-me']),
|
||||||
|
set(commits[3]['blueprint_id']))
|
||||||
|
|
||||||
self.assertEquals(0, commits[4]['files_changed'])
|
self.assertEquals(0, commits[4]['files_changed'])
|
||||||
self.assertEquals(0, commits[4]['lines_added'])
|
self.assertEquals(0, commits[4]['lines_added'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user