Skip to content

Instantly share code, notes, and snippets.

@erikvanzijst
Last active December 21, 2015 11:49
Show Gist options
  • Save erikvanzijst/6301400 to your computer and use it in GitHub Desktop.
Save erikvanzijst/6301400 to your computer and use it in GitHub Desktop.
import requests, re, sys
from urllib import urlencode
refs = [(ref[0] == '^' and 'exclude' or 'include', re.sub(r'^\^', '', ref))
for ref in sys.argv[2:]]
url = ('/2.0/repositories/%s/commits?%s' % (sys.argv[1], urlencode(refs)))
while url:
doc = requests.get('https://api.bitbucket.org' + url).json()
for cset in doc['values']:
print cset['hash'][:7], cset['message'].splitlines()[0]
url = doc.get('next')
@erikvanzijst
Copy link
Author

Traverses the commits in a Bitbucket repo:

$ python bblog.py pypy/pypy release-2.0.2 ^release-2.0.1

analogous to what git log would give:

$ git log --oneline --date-order ref1 ref2 ^ref3 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment