def get_issue_comments()

in migration/src/github_issues_util.py [0:0]


def get_issue_comments(token: str, repo: str, issue_number: int, logger: Logger) -> list[GHIssueComment]:
    url = GITHUB_API_BASE + f"/repos/{repo}/issues/{issue_number}/comments?per_page=100"
    headers = {"Authorization": f"token {token}", "Accept": "application/vnd.github.v3+json"}
    li = []
    stop = False
    page = 1
    while not stop:
        url_with_paging = url + f"&page={page}"
        res = requests.get(url_with_paging, headers=headers)
        time.sleep(INTERVAL_IN_SECONDS)
        if res.status_code != 200:
            logger.error(f"Failed to get issue comments for {issue_number}; status_code={res.status_code}, message={res.text}")
            break
        if not res.json():
            stop = True
        for comment in res.json():
            li.append(GHIssueComment(id=comment.get("id"), body=comment.get("body")))
        page += 1
    return li