Skip to content

Instantly share code, notes, and snippets.

@thedaniel
Created February 10, 2020 16:26
Show Gist options
  • Save thedaniel/aca099f7caca75ad9b76f96a9cd1168d to your computer and use it in GitHub Desktop.
Save thedaniel/aca099f7caca75ad9b76f96a9cd1168d to your computer and use it in GitHub Desktop.
Show all the issue and PR comments where you're the last one to comment so you can hunt people down
# python i-showed-you-my-code-please-respond.py <org name> <auth token>
import csv
import sys
from operator import attrgetter
# pip install PyGithub
from github import Github
hub = Github(sys.argv[2])
org = hub.get_organization(sys.argv[1])
my_comments = []
def get_my_comments_for_issues(issues):
ret = []
for issue in issues:
comments = []
try:
comments = issue.get_issue_comments()
except AttributeError:
comments = issue.get_comments()
latest = max(comments, key=attrgetter('created_at')) if comments.totalCount > 0 else None
if latest and latest.user.login == 'thedaniel':
ret.append(latest)
return ret
for repo in org.get_repos():
issues = repo.get_issues(state='open')
pulls = repo.get_pulls(state='open')
my_comments += get_my_comments_for_issues(issues)
my_comments += get_my_comments_for_issues(pulls)
my_comments.sort(key = lambda c: c.created_at)
with open('comments.csv', mode='w') as csv_file:
writer = csv.writer(csv_file)
for row in [[x.created_at, x.body, x.html_url] for x in my_comments]:
writer.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment