1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
todoist-github/todoist_github/tasks/prs_to_review.py

25 lines
942 B
Python
Raw Normal View History

2020-01-19 20:04:14 +00:00
import logging
2020-01-09 18:59:34 +00:00
from todoist_github.clients import github, todoist
from todoist_github.utils.todoist import get_relevant_todoist_tasks, pr_to_task_name
SEARCH_STRING = "is:pr review-requested:{username} archived:false"
def prs_to_review():
relevant_tasks = get_relevant_todoist_tasks(todoist)
me = github.get_user()
search_string = SEARCH_STRING.format(username=me.login)
tasks_actioned = []
for issue in github.search_issues(search_string):
task = relevant_tasks.get(issue.html_url)
if not task and issue.state == "open":
2020-01-19 20:02:13 +00:00
logging.info("Creating '%s'", issue.title)
2020-01-09 18:59:34 +00:00
task = todoist.items.add(pr_to_task_name(issue))
if not task:
continue
tasks_actioned.append(task["id"])
if task["content"] != pr_to_task_name(issue):
2020-01-19 20:02:13 +00:00
logging.info("Updating issue name for '%s'", issue.title)
2020-01-09 18:59:34 +00:00
task.update(content=pr_to_task_name(issue))