Created
December 1, 2016 11:41
-
-
Save sjcorbett/72ed944b06ce3a138fbe516e8d36f624 to your computer and use it in GitHub Desktop.
Writes brooklyn-server PRs merged since a date to a file
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
#!/usr/bin/env python | |
from datetime import date | |
from github import Github | |
# Date of last release. | |
not_before = date(2016, 4, 8) | |
# Set vim's foldmethod to marker | |
add_fold_markers = True | |
open_fold = "{{{ " | |
close_fold = "}}}" | |
# See https://github.com/settings/tokens | |
user = "..." | |
token = "..." | |
g = Github(user, token) | |
def merged_since(since=not_before): | |
r = g.get_repo("apache/brooklyn-server") | |
for pr in r.get_pulls(state="closed"): | |
if pr.merged and (pr.merged_at.date() >= since): | |
yield pr | |
# TODO: Could load template from file and interpolate with pr object fields. Then no need for foldmarkers etc. | |
with open('/tmp/output', 'w') as f: | |
for pr in merged_since(not_before): | |
title = "#%d: %s" % (pr.number, pr.title.encode('utf-8').strip()) | |
print "Adding " + title | |
if add_fold_markers: | |
title = open_fold + title | |
f.write(title) | |
f.write("\n") | |
f.write('-' * len(title)) | |
f.write("\n") | |
f.write(pr.html_url) | |
f.write("\n\n") | |
f.write(pr.body.encode('utf-8').strip()) | |
f.write("\n\n") | |
if add_fold_markers: | |
f.write(close_fold) | |
f.write("\n") |
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
# Version must be > 1.29 if using Python 2 (i.e. one that has https://github.com/PyGithub/PyGithub/pull/495) | |
# 1.29 is the latest release as of 2016-12-01. | |
PyGithub > 1.29 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment