Skip to content

Commit

Permalink
Docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Nov 20, 2024
1 parent ed2f201 commit b3284c9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .github/scripts/post_lab_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,34 @@


def get_comment_id():
"""Fetches PR comments and finds one with the unique identifier."""
"""Fetches PR comments and scans for the COMMENT_ID_STRING."""
for comment in pull_request.get_issue_comments():
if COMMENT_ID_STRING in comment.body:
return comment.id
return None


def update_comment(comment_id, new_body):
"""Updates an existing comment by ID with new content."""
"""Updates an existing comment by ID with new body in markdown format."""
comment = repo.get_issue_comment(comment_id)
tagged_body = f"{new_body}\n\n{COMMENT_ID_STRING}"
comment.edit(tagged_body)
print("Comment updated successfully.")


def create_comment(new_body):
"""Creates a new comment on the PR."""
"""Creates a new comment on the PR with a body in markdown format."""
tagged_body = f"{new_body}\n\n{COMMENT_ID_STRING}"
pull_request.create_issue_comment(tagged_body)
print("Comment created successfully.")


def create_or_update_comment(new_body):
"""Creates or updates a comment with the unique identifier."""
"""Creates or updates a comment with the given body in markdown format.
Checks for an existing comment by looking for the COMMENT_ID_STRING
in existing comments.
"""
comment_id = get_comment_id()
if comment_id:
update_comment(comment_id, new_body)
Expand Down

0 comments on commit b3284c9

Please sign in to comment.