Created
February 6, 2017 16:55
-
-
Save ceddlyburge/731e8d105f4377379531ca34dacacaae to your computer and use it in GitHub Desktop.
Print organisation commits on github since date. This queries the github api using a personal access token. The token in this gist has been deleted.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def print_commit(commit): | |
if "sha" in commit: | |
print("{},{},{},\"{}\"".format(commit["sha"], commit["commit"]["author"]["date"], commit["commit"]["author"]["name"], commit["commit"]["message"]).replace("\r", "").replace("\n", "")) | |
else: | |
print(commit) | |
def print_commits(repository_name): | |
print(repository_name) | |
[print_commit(commit) for commit in commits_json(repository_name)] | |
def commits_json(repository_name): | |
return requests.get("https://api.github.com/repos/{}/commits?since=2017-01-01".format(repository_name), | |
headers={'Authorization': 'token 1bd861ee644aa99944ffa0ca43e191d929c34c03'}).json() | |
def repositories_json(): | |
return requests.get("https://api.github.com/orgs/resgroup/repos?page=1&per_page=10000", | |
headers={'Authorization': 'token 1bd861ee644aa99944ffa0ca43e191d929c34c03'}).json() | |
[print_commits(repository_name["full_name"]) for repository_name in repositories_json()] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment