Skip to content

Instantly share code, notes, and snippets.

@lplume
Last active April 30, 2018 07:07
Show Gist options
  • Save lplume/c1fde583322a90fa1d59b97de6f79270 to your computer and use it in GitHub Desktop.
Save lplume/c1fde583322a90fa1d59b97de6f79270 to your computer and use it in GitHub Desktop.
Get updates from you starred repos
from sys import argv
from agithub.GitHub import GitHub
# pip install agithub
# argv[1] = github login name
## sample out
# repo: miyakogi/pyppeteer
# fork: source
# description: Headless chrome/chromium automation library (unofficial port of puppeteer)
# url: https://github.com/miyakogi/pyppeteer
#
# * (miyakogi) Merge tag '0.0.16' into dev 0.0.16
# * (miyakogi) Merge branch 'release/0.0.16'
# * (miyakogi) Bump version: 0.0.15 → 0.0.16
def lastCommit(g, repo):
clogin, crepo = repo['owner']['login'], repo['name']
status, commits = g.repos[clogin][crepo].commits.get(per_page=3)
return commits
def forkToText(val):
return 'yes' if val else 'source'
def renderRepoInfo(data):
tpl = "\nrepo: %s\nfork: %s\ndescription: %s\nurl: %s\n"
return tpl % (s['full_name'], forkToText(s['fork']), s['description'], s['html_url'])
def renderCommitsInfo(data):
tpl = "\t* (%s) %s"
author = data['author']['login'] if data['author'] else data['commit']['author']['email']
return tpl % (data['commit']['author']['date'], author, data['commit']['message'].replace('\n', ' ').replace('\r', ''))
g = GitHub() # GitHub('user', 'password')
login, repo = argv[1], 'starred'
status, starred = g.users[login][repo].get(sort='updated', per_page=5)
for s in starred:
print(renderRepoInfo(s))
commits = lastCommit(g, s)
for c in commits:
print(renderCommitsInfo(c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment