Only create tasks if I was asked to review them

This commit is contained in:
Jake Howard 2019-10-13 20:35:29 +01:00
parent ab1b3fee59
commit 1ac2abcab5
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -20,6 +20,14 @@ def get_my_review(me, pr: PullRequest):
return review return review
def get_my_review_requested(me, pr: PullRequest) -> bool:
reviewing_users, _ = pr.get_review_requests()
for user in reviewing_users:
if user.login == me.login:
return True
return False
def todoist_repo_prs(): def todoist_repo_prs():
todoist = get_todoist_client() todoist = get_todoist_client()
me = github.get_user() me = github.get_user()
@ -64,7 +72,11 @@ def todoist_repo_prs():
todoist.items.unarchive(existing_task_id) todoist.items.unarchive(existing_task_id)
todoist.items.uncomplete(existing_task_id) todoist.items.uncomplete(existing_task_id)
continue continue
elif my_review and my_review.commit_id != pr.head.sha: elif (
get_my_review_requested(me, pr)
and my_review
and my_review.commit_id != pr.head.sha
):
logger.info("Creating task to review '{}'".format(pr.title)) logger.info("Creating task to review '{}'".format(pr.title))
existing_task_id = todoist.items.add( existing_task_id = todoist.items.add(
pr_to_task_name(pr), project_id=project_id pr_to_task_name(pr), project_id=project_id