Created
February 26, 2016 23:26
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 xml.etree.ElementTree as ET | |
from urllib.parse import urlparse, parse_qs | |
import github | |
ID = "" | |
SECRET = "" | |
COMMENT_TEMPLATE ="""Hello stranger, thanks for your contribution to GNOME. | |
Unfortunately the GNOME repositories in the GitHub mirror do not accept pull requests. | |
The GNOME project requires contributions to be sent as rebased patches to Bugzilla, although some maintainers are happy to do the rebase work themselves from a GitHub pull request branch. | |
GNOME is a large project with a long commit history, spanning many years, and unfortunately the GitHub merge workflow creates an obfuscated commit log that makes the life of the maintainers really hard in the long run. | |
Please do not take this as a rejection of your contribution, GNOME needs and relies on the support of volunteers all over the world, and we need people like you. | |
We would really appreciate it if you could create a GNOME bugzilla account in case you don't have one already and file a bug there with either an attachment or at least a link to your branch in github: | |
%s | |
Again, thanks again for the time you're commiting to improve GNOME. | |
Happy hacking! | |
""" | |
def get_pulls(gh): | |
foo = gh.search_issues("type:pull user:gnome state:open") | |
return foo | |
def pull_check_attended(pr): | |
pass | |
def get_bugzilla_url(xml): | |
DEFAULT = "https://bugzilla.gnome.org/enter_bug.cgi?classification=__all" | |
tree = ET.fromstring(xml) | |
bug_database = tree.find("{http://usefulinc.com/ns/doap#}bug-database") | |
if bug_database is None: | |
return DEFAULT | |
bzurl = bug_database.get ("{http://www.w3.org/1999/02/22-rdf-syntax-ns#}resource", DEFAULT) | |
product = parse_qs(urlparse(bzurl).query).get("product", None) | |
if product is None: | |
return DEFAULT | |
return "https://bugzilla.gnome.org/enter_bug.cgi?product="+product[0] | |
def inform_and_close (pr, bz): | |
content = COMMENT_TEMPLATE % bz | |
print (pr.html_url) | |
gh_comment = pr.create_comment(content) | |
print (gh_comment.html_url) | |
def main(): | |
gh = github.Github("user", "pw") | |
pulls = get_pulls(gh) | |
doaps = {} | |
for p in pulls: | |
doap = None | |
print (p.repository.name) | |
if p.repository.name in ["ostree", "libglnx"]: | |
continue | |
for f in p.repository.get_dir_contents("/"): | |
if f.name.endswith(".doap"): | |
doap = p.repository.get_contents("/" + f.name) | |
inform_and_close(p, get_bugzilla_url(doap.decoded_content)) | |
break | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment