Skip to content

Instantly share code, notes, and snippets.

@shackra
Created March 12, 2026 22:44
Show Gist options
  • Select an option

  • Save shackra/240170f8d4b06925519426fb52610674 to your computer and use it in GitHub Desktop.

Select an option

Save shackra/240170f8d4b06925519426fb52610674 to your computer and use it in GitHub Desktop.
List all comments mentioning you in any PR comment, within the last 3 days
gh api graphql -f query='
query {
search(query: "is:pr mentions:@me", type: ISSUE, first: 50) {
nodes {
... on PullRequest {
number
title
url
repository { nameWithOwner }
comments(last: 100) {
nodes {
author { login }
body
url
createdAt
}
}
}
}
}
}' | python3 -c '
import json, sys, time, re
from datetime import datetime, timezone, timedelta
import humanize # do not forget to install humanize library!
GREEN = "\033[32m"
DARK = "\033[90m"
LIGHT = "\033[1m"
RESET = "\033[0m"
now = datetime.now().astimezone()
three_days = timedelta(days=3)
data = json.load(sys.stdin)
for pr in data["data"]["search"]["nodes"]:
for comment in pr["comments"]["nodes"]:
body = comment["body"]
created = datetime.fromisoformat(comment["createdAt"]).astimezone()
rfc2822 = created.strftime("%a, %d %b %Y %H:%M")
how_ago = now - created
ago = humanize.naturaltime(how_ago)
if how_ago.total_seconds() > three_days.total_seconds():
continue
colored_body = re.sub(r"(@\w+)", f"{LIGHT}\\1{RESET}", body)
print(f"{GREEN}From:{RESET} {comment["author"]["login"]}{RESET}")
print(f"{GREEN}Date:{RESET} {rfc2822} ({ago}){RESET}")
print()
print(colored_body)
print()
print(f"--")
print(f"{DARK}{comment["url"]}{RESET}")
print()
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment