Blob Blame History Raw
#!/usr/bin/python3

import requests
import json
import click


@click.command()
@click.argument('base', nargs=1)
@click.argument('head', nargs=1)
def cli(base, head):
    r = requests.get('https://api.github.com/repos/github/hub/compare/%s...%s' % (base, head))

    data = r.json()

    if not data['status'] == 'ahead':
        raise IOError("Branches are divergent")

    for commit in data['commits']:
        print("- ", commit['commit']['message'].split('\n')[0])


def main():
    cli(obj={})


if __name__ == "__main__":
    main()