Created
June 9, 2015 15:43
-
-
Save pentaho-nbaker/e6b679694df857f6307b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| __author__ = 'nbaker' | |
| import requests | |
| import json | |
| import time | |
| if __name__ == '__main__': | |
| unmerged_pulls = [] | |
| errored_pulls = [] | |
| auto_merged = [] | |
| headers = {'content-type': 'application/json', | |
| "Content-Type": "application/json", | |
| "Accept": "application/json"} | |
| params = {'per_page':1000} | |
| next = 'https://api.github.com/orgs/pentaho/repos?page=1' | |
| page = 1 | |
| while True: | |
| page += 1 | |
| next = 'https://api.github.com/orgs/pentaho/repos?page='+str(page) | |
| repos_request = requests.get(next, auth=('buildguy', 'S6ddxtky'), headers=headers, params=params) | |
| repos = repos_request.json() | |
| if len(repos) == 0: | |
| break | |
| urls = [rep["url"] for rep in repos] | |
| for url in urls: | |
| time.sleep(5) | |
| print "processing: "+url | |
| params = { | |
| "title": "Auto-Merge refreshing development branch", | |
| "body": "Merge of master into future-develop", | |
| "head": "master", | |
| "base": "future-develop" | |
| } | |
| url = url + "/pulls" | |
| response = requests.post(url, auth=('buildguy', 'S6ddxtky'), | |
| data=json.dumps(params)) | |
| print response.text | |
| pull = response.json() | |
| if "errors" in pull: | |
| errored_pulls.append( url + str(pull["errors"]) ) | |
| else: | |
| commit_message = {"commit_message" : "Auto Merge of master into future-develop"} | |
| pull_url = pull["url"] + "/merge" | |
| response = requests.put(pull_url, auth=('buildguy', 'S6ddxtky'), data=json.dumps(params)) | |
| print response.text | |
| merge_result = response.json() | |
| if "merged" not in merge_result or merge_result["merged"] is False: | |
| print "not mergable or merge failed: "+pull_url | |
| unmerged_pulls.append(pull_url) | |
| else: | |
| auto_merged.append(url) | |
| print "\n\nerrored:" | |
| for errored in errored_pulls: | |
| print errored | |
| print "\n\nUnmerged:" | |
| for unmerged in unmerged_pulls: | |
| print unmerged | |
| print "\n\nAuto Merged:" | |
| for merged in auto_merged: | |
| print merged |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment