Skip to content

Instantly share code, notes, and snippets.

@sergray
Last active August 29, 2015 14:19
Show Gist options
  • Save sergray/a7cf81e2061b0b591e8a to your computer and use it in GitHub Desktop.
Save sergray/a7cf81e2061b0b591e8a to your computer and use it in GitHub Desktop.
Save commits from multiple GitHub pull requests into text files just in one bash line (requires Python flatdict)
$ for p in NUM1 NUM2; do curl -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token OAUTH-TOKEN" \
https://api.github.com/repos/:ORG:/:REPO:/pulls/$p/commits | \
python -c "from flatdict import FlatDict; import json, csv, sys; rows = json.load(sys.stdin); \
writer = csv.DictWriter(sys.stdout, [u'commit:author:name', u'commit:author:date', u'commit:tree:sha', u'commit:message'], extrasaction='ignore', delimiter='\t'); writer.writerows(FlatDict(row) for row in rows)" \
> GH-PR-$p.txt; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment