Improve handling of tagging and Github app user interaction

This commit is contained in:
Ori Kotek
2023-07-06 12:58:05 +03:00
parent 0ebd29d398
commit b6333e7f20
5 changed files with 44 additions and 9 deletions

View File

@ -24,6 +24,7 @@ class GithubProvider:
self.repo = None
self.pr_num = None
self.pr = None
self.github_user_id = None
if pr_url:
self.set_pr(pr_url)
@ -42,6 +43,8 @@ class GithubProvider:
def publish_comment(self, pr_comment: str, is_temporary: bool = False):
response = self.pr.create_issue_comment(pr_comment)
if hasattr(response, "user") and hasattr(response.user, "login"):
self.github_user_id = response.user.login
response.is_temporary = is_temporary
if not hasattr(self.pr, 'comments_list'):
self.pr.comments_list = []
@ -109,6 +112,14 @@ class GithubProvider:
def get_pr_branch(self):
return self.pr.head.ref
def get_user_id(self):
if not self.github_user_id:
try:
self.github_user_id = self.github_client.get_user().login
except Exception as e:
logging.exception(f"Failed to get user id, error: {e}")
return self.github_user_id
def get_notifications(self, since: datetime):
deployment_type = settings.get("GITHUB.DEPLOYMENT_TYPE", "user")