Skip to content

Commit

Permalink
Merge d1db739 into bf90a3c
Browse files Browse the repository at this point in the history
  • Loading branch information
tosky committed Mar 14, 2019
2 parents bf90a3c + d1db739 commit 877db83
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions did/plugins/gerrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@ class GerritUnit(Stats):
Gerrit repo.
"""
def __init__(
self, option, name=None, parent=None, base_url=None, prefix=None):
self, option, name=None, parent=None, base_url=None, prefix=None,
server_features=None):
self.base_url = base_url if base_url is not None else parent.repo_url
self.prefix = prefix if prefix is not None else parent.config['prefix']
self.repo = Gerrit(baseurl=self.base_url, prefix=self.prefix)
self.since_date = None
self.server_features = []
if server_features:
self.server_features = server_features

Stats.__init__(self, option, name, parent)

Expand Down Expand Up @@ -234,7 +238,11 @@ class SubmitedChanges(GerritUnit):
"""
def fetch(self):
log.info(u"Searching for changes opened by {0}".format(self.user))
self.stats = GerritUnit.fetch(self, 'status:open -is:wip',
if 'wip' in self.server_features:
query_string = 'status:open -is:wip'
else:
query_string = 'status:open'
self.stats = GerritUnit.fetch(self, query_string,
limit_since=True)
log.debug(u"self.stats = {0}".format(self.stats))

Expand All @@ -244,6 +252,9 @@ class WIPChanges(GerritUnit):
"""
def fetch(self):
log.info(u"Searching for WIP changes opened by {0}".format(self.user))
if 'wip' not in self.server_features:
log.debug(u"WIP reviews are not supported by this server")
return []
self.stats = GerritUnit.fetch(self, 'status:open is:wip',
limit_since=True)
log.debug(u"self.stats = {0}".format(self.stats))
Expand Down Expand Up @@ -388,11 +399,21 @@ def __init__(self, option, name=None, parent=None, user=None):
raise ReportError(
"No prefix set in the [{0}] section".format(option))

server_features = []
if self.config.get('wip', True) == True:
server_features.append('wip')

self.stats = [
AbandonedChanges(option=option + '-abandoned', parent=self),
MergedChanges(option=option + '-merged', parent=self),
SubmitedChanges(option=option + '-submitted', parent=self),
WIPChanges(option=option + '-wip', parent=self),
#AddedPatches(option=option + '-added-patches', parent=self),
ReviewedChanges(option=option + '-reviewed', parent=self),
AbandonedChanges(option=option + '-abandoned', parent=self,
server_features=server_features),
MergedChanges(option=option + '-merged', parent=self,
server_features=server_features),
SubmitedChanges(option=option + '-submitted', parent=self,
server_features=server_features),
WIPChanges(option=option + '-wip', parent=self,
server_features=server_features),
#AddedPatches(option=option + '-added-patches', parent=self,
# server_features=server_features),
ReviewedChanges(option=option + '-reviewed', parent=self,
server_features=server_features),
]

0 comments on commit 877db83

Please sign in to comment.