diff options
| -rw-r--r-- | .ci/scripts/merge/apply-patches-by-label-private.py | 50 | ||||
| -rw-r--r-- | .ci/scripts/merge/apply-patches-by-label.py | 10 |
2 files changed, 35 insertions, 25 deletions
diff --git a/.ci/scripts/merge/apply-patches-by-label-private.py b/.ci/scripts/merge/apply-patches-by-label-private.py index 6e3cb995e..fe0acd510 100644 --- a/.ci/scripts/merge/apply-patches-by-label-private.py +++ b/.ci/scripts/merge/apply-patches-by-label-private.py | |||
| @@ -1,41 +1,45 @@ | |||
| 1 | # Download all pull requests as patches that match a specific label | 1 | # Download all pull requests as patches that match a specific label |
| 2 | # Usage: python download-patches-by-label.py <Label to Match> <Root Path Folder to DL to> | 2 | # Usage: python download-patches-by-label.py <Label to Match> <Root Path Folder to DL to> |
| 3 | 3 | ||
| 4 | import requests, sys, json, urllib3.request, shutil, subprocess, os, traceback | 4 | import requests, sys, json, shutil, subprocess, os, traceback |
| 5 | 5 | ||
| 6 | org = os.getenv("PrivateMergeOrg".upper(), "yuzu-emu") | 6 | org = os.getenv("PRIVATEMERGEORG", "yuzu-emu") |
| 7 | repo = os.getenv("PrivateMergeRepo".upper(), "yuzu-private") | 7 | repo = os.getenv("PRIVATEMERGEREPO", "yuzu-private") |
| 8 | tagline = sys.argv[3] | 8 | tagline = sys.argv[3] |
| 9 | user = sys.argv[1] | 9 | user = sys.argv[1] |
| 10 | 10 | ||
| 11 | http = urllib3.PoolManager() | ||
| 12 | dl_list = {} | 11 | dl_list = {} |
| 13 | 12 | ||
| 13 | TAG_NAME = sys.argv[2] | ||
| 14 | |||
| 14 | def check_individual(repo_id, pr_id): | 15 | def check_individual(repo_id, pr_id): |
| 15 | url = 'https://%sdev.azure.com/%s/%s/_apis/git/repositories/%s/pullRequests/%s/labels?api-version=5.1-preview.1' % (user, org, repo, repo_id, pr_id) | 16 | url = 'https://%sdev.azure.com/%s/%s/_apis/git/repositories/%s/pullRequests/%s/labels?api-version=5.1-preview.1' % (user, org, repo, repo_id, pr_id) |
| 16 | response = requests.get(url) | 17 | response = requests.get(url) |
| 17 | if (response.ok): | 18 | if (response.ok): |
| 18 | j = json.loads(response.content) | 19 | try: |
| 19 | for tg in j['value']: | 20 | js = response.json() |
| 20 | if (tg['name'] == sys.argv[2]): | 21 | return any(tag.get('name') == TAG_NAME for tag in js['value']) |
| 21 | return True | 22 | except: |
| 23 | return False | ||
| 22 | return False | 24 | return False |
| 23 | 25 | ||
| 24 | try: | 26 | def merge_pr(pn, ref): |
| 27 | print("Matched PR# %s" % pn) | ||
| 28 | print(subprocess.check_output(["git", "fetch", "https://%sdev.azure.com/%s/_git/%s" % (user, org, repo), ref, "-f"])) | ||
| 29 | print(subprocess.check_output(["git", "merge", "--squash", 'origin/' + ref.replace('refs/heads/','')])) | ||
| 30 | print(subprocess.check_output(["git", "commit", "-m\"Merge %s PR %s\"" % (tagline, pn)])) | ||
| 31 | |||
| 32 | def main(): | ||
| 25 | url = 'https://%sdev.azure.com/%s/%s/_apis/git/pullrequests?api-version=5.1' % (user, org, repo) | 33 | url = 'https://%sdev.azure.com/%s/%s/_apis/git/pullrequests?api-version=5.1' % (user, org, repo) |
| 26 | response = requests.get(url) | 34 | response = requests.get(url) |
| 27 | if (response.ok): | 35 | if (response.ok): |
| 28 | j = json.loads(response.content) | 36 | js = response.json() |
| 29 | for pr in j["value"]: | 37 | tagged_prs = filter(lambda pr: check_individual(pr['repository']['id'], pr['pullRequestId']), js['value']) |
| 30 | repo_id = pr['repository']['id'] | 38 | map(lambda pr: merge_pr(pr['pullRequestId'], pr['sourceRefName']), tagged_prs) |
| 31 | pr_id = pr['pullRequestId'] | 39 | |
| 32 | if (check_individual(repo_id, pr_id)): | 40 | if __name__ == '__main__': |
| 33 | pn = pr_id | 41 | try: |
| 34 | ref = pr['sourceRefName'] | 42 | main() |
| 35 | print("Matched PR# %s" % pn) | 43 | except: |
| 36 | print(subprocess.check_output(["git", "fetch", "https://%sdev.azure.com/%s/_git/%s" % (user, org, repo), ref, "-f"])) | 44 | traceback.print_exc(file=sys.stdout) |
| 37 | print(subprocess.check_output(["git", "merge", "--squash", 'origin/' + ref.replace('refs/heads/','')])) | 45 | sys.exit(-1) |
| 38 | print(subprocess.check_output(["git", "commit", "-m\"Merge %s PR %s\"" % (tagline, pn)])) | ||
| 39 | except: | ||
| 40 | traceback.print_exc(file=sys.stdout) | ||
| 41 | sys.exit(-1) | ||
diff --git a/.ci/scripts/merge/apply-patches-by-label.py b/.ci/scripts/merge/apply-patches-by-label.py index e81db9287..43ed74d7f 100644 --- a/.ci/scripts/merge/apply-patches-by-label.py +++ b/.ci/scripts/merge/apply-patches-by-label.py | |||
| @@ -14,11 +14,13 @@ def check_individual(labels): | |||
| 14 | return True | 14 | return True |
| 15 | return False | 15 | return False |
| 16 | 16 | ||
| 17 | try: | 17 | def do_page(page): |
| 18 | url = 'https://api.github.com/repos/yuzu-emu/yuzu/pulls' | 18 | url = 'https://api.github.com/repos/yuzu-emu/yuzu/pulls?page=%s' % page |
| 19 | response = requests.get(url) | 19 | response = requests.get(url) |
| 20 | if (response.ok): | 20 | if (response.ok): |
| 21 | j = json.loads(response.content) | 21 | j = json.loads(response.content) |
| 22 | if j == []: | ||
| 23 | return | ||
| 22 | for pr in j: | 24 | for pr in j: |
| 23 | if (check_individual(pr["labels"])): | 25 | if (check_individual(pr["labels"])): |
| 24 | pn = pr["number"] | 26 | pn = pr["number"] |
| @@ -26,5 +28,9 @@ try: | |||
| 26 | print(subprocess.check_output(["git", "fetch", "https://github.com/yuzu-emu/yuzu.git", "pull/%s/head:pr-%s" % (pn, pn), "-f"])) | 28 | print(subprocess.check_output(["git", "fetch", "https://github.com/yuzu-emu/yuzu.git", "pull/%s/head:pr-%s" % (pn, pn), "-f"])) |
| 27 | print(subprocess.check_output(["git", "merge", "--squash", "pr-%s" % pn])) | 29 | print(subprocess.check_output(["git", "merge", "--squash", "pr-%s" % pn])) |
| 28 | print(subprocess.check_output(["git", "commit", "-m\"Merge %s PR %s\"" % (tagline, pn)])) | 30 | print(subprocess.check_output(["git", "commit", "-m\"Merge %s PR %s\"" % (tagline, pn)])) |
| 31 | |||
| 32 | try: | ||
| 33 | for i in range(1,30): | ||
| 34 | do_page(i) | ||
| 29 | except: | 35 | except: |
| 30 | sys.exit(-1) | 36 | sys.exit(-1) |