Add cross-source tests

Change-Id: Iaf31211d12a2c8ce3b4a2860e079748f7e705aba
Story: 2001334
Task: 5885
This commit is contained in:
James E. Blair
2018-01-10 16:07:41 -08:00
parent 0e4c791c7b
commit 54145e0fd9
20 changed files with 1198 additions and 5 deletions

View File

@@ -70,13 +70,15 @@ class GerritSource(BaseSource):
return change
def getChangesDependingOn(self, change, projects):
changes = []
if not change.uris:
return changes
queries = set()
for uri in change.uris:
queries.add('message:%s' % uri)
query = '(' + ' OR '.join(queries) + ')'
results = self.connection.simpleQuery(query)
seen = set()
changes = []
for result in results:
for match in find_dependency_headers(result['commitMessage']):
found = False

View File

@@ -646,9 +646,12 @@ class GithubConnection(BaseConnection):
return self._github
def maintainCache(self, relevant):
remove = set()
for key, change in self._change_cache.items():
if change not in relevant:
del self._change_cache[key]
remove.add(key)
for key in remove:
del self._change_cache[key]
def getChange(self, event, refresh=False):
"""Get the change representing an event."""
@@ -661,7 +664,6 @@ class GithubConnection(BaseConnection):
change.uris = [
'%s/%s/pull/%s' % (self.server, project, change.number),
]
change.updated_at = self._ghTimestampToDate(event.updated_at)
change.source_event = event
change.is_current_patchset = (change.pr.get('head').get('sha') ==
event.patch_number)
@@ -789,6 +791,8 @@ class GithubConnection(BaseConnection):
change.labels = change.pr.get('labels')
# ensure message is at least an empty string
change.message = change.pr.get('body') or ''
change.updated_at = self._ghTimestampToDate(
change.pr.get('updated_at'))
if history is None:
history = []

View File

@@ -46,6 +46,8 @@ class GithubSource(BaseSource):
if not change.number:
# Not a pull request, considering merged.
return True
# We don't need to perform another query because the API call
# to perform the merge will ensure this is updated.
return change.is_merged
def canMerge(self, change, allow_needs):