in migration/src/remap_cross_issue_links.py [0:0]
def remap_issue_link_in_comments(issue_number: int, issue_id_map: dict[str, int], data_dir: Path, token: str, repo: str):
comments = get_issue_comments(token, repo, issue_number, logger)
if not comments:
return
logger.debug(f"# comments in issue {issue_number} = {len(comments)}")
for comment in comments:
id = comment.id
body = comment.body
updated_body = embed_gh_issue_link(body, issue_id_map, issue_number)
updated_body = create_issue_links_outside_projects(updated_body)
if updated_body == body:
logger.debug(f"Comment {id} does not contain any cross-issue links; nothing to do.")
continue
data = {"comment_id": id, "body": updated_body}
data_file = github_remapped_comment_data_file(data_dir, id)
with open(data_file, "w") as fp:
json.dump(data, fp=fp, indent=2)
logger.debug(f"Updated comment body for comment_id={id} was saved to {data_file}.")