Fix github app authentication in _getNeededByFromPR

When running as a github app we must supply the project in order to do
proper authentication as the installation. Otherwise we end up as an
unauthenticated request which will be rejected by most GHE
installations.

A draw back currently is that the search will be scoped by the app
installation (which is either a single repository or an
organization). As a future improvement we might want to iterate over
all installation and do the query. However this would need to be
configurable as with many installations this quickly can become quite
expensive. A different optimization could be searching in the local
change cache.

Change-Id: Iee7f009693dc8afa4631d2e48a630bb6da689aec
This commit is contained in:
Tobias Henkel 2017-12-15 16:28:12 +01:00
parent 467bf8be7d
commit 6619d64269
1 changed files with 2 additions and 1 deletions

View File

@ -709,7 +709,8 @@ class GithubConnection(BaseConnection):
change.project.name,
change.number)
query = '%s type:pr is:open in:body' % pattern
github = self.getGithubClient()
# FIXME(tobiash): find a way to query this for different installations
github = self.getGithubClient(change.project.name)
for issue in github.search_issues(query=query):
pr = issue.issue.pull_request().as_dict()
if not pr.get('url'):