summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-04-29 00:01:40 +0000
committerGerrit Code Review <review@openstack.org>2022-04-29 00:01:40 +0000
commit3192f4d2eba7e671b69970febc7d8564a698a086 (patch)
tree094b446f0715f2b0f4b85e72cc5030769cf5fd73 /tools
parent6c6ebc7b5df6bb323e09b1f45229223c080646ae (diff)
parente4e7fd831e430648b5988b5a9af2f214e3b613b2 (diff)
downloadzuul-3192f4d2eba7e671b69970febc7d8564a698a086.tar.gz
Merge "Fix Github debugging script"
Diffstat (limited to 'tools')
-rwxr-xr-xtools/github-debugging.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/github-debugging.py b/tools/github-debugging.py
index da6fd0c66..afc8159d6 100755
--- a/tools/github-debugging.py
+++ b/tools/github-debugging.py
@@ -1,10 +1,12 @@
#!/usr/bin/env python3
import logging
+from collections import UserDict
from zuul.driver.github.githubconnection import GithubConnection
from zuul.driver.github import GithubDriver
-from zuul.model import Change, Project
+from zuul.model import Change
+from zuul.zk.change_cache import ChangeKey
# This is a template with boilerplate code for debugging github issues
@@ -19,6 +21,14 @@ repo = 'sandbox'
pull_nr = 8
+class DummyChangeCache(UserDict):
+
+ def updateChangeWithRetry(self, key, change, update_func, retry_count=5):
+ update_func(change)
+ self[key] = change
+ return change
+
+
def configure_logging(context):
stream_handler = logging.StreamHandler()
logger = logging.getLogger(context)
@@ -40,7 +50,8 @@ def create_connection(server, api_token):
'api_token': api_token,
}
conn = GithubConnection(driver, 'github', connection_config)
- conn._authenticateGithubAPI()
+ conn._github_client_manager.initialize()
+ conn._change_cache = DummyChangeCache()
return conn
@@ -52,8 +63,8 @@ def create_connection_app(server, appid, appkey):
'app_key': appkey,
}
conn = GithubConnection(driver, 'github', connection_config)
- conn._authenticateGithubAPI()
- conn._prime_installation_map()
+ conn._github_client_manager.initialize()
+ conn._change_cache = DummyChangeCache()
return conn
@@ -61,11 +72,12 @@ def get_change(connection: GithubConnection,
org: str,
repo: str,
pull: int) -> Change:
- p = Project("%s/%s" % (org, repo), connection.source)
- github = connection.getGithubClient(p.name)
+ project_name = f"{org}/{repo}"
+ github = connection.getGithubClient(project_name)
pr = github.pull_request(org, repo, pull)
sha = pr.head.sha
- return conn._getChange(p, pull, sha, True)
+ change_key = ChangeKey('github', project_name, 'PullRequest', pull, sha)
+ return conn._getChange(change_key, refresh=True)
# create github connection with api token