diff options
Diffstat (limited to '')
| -rw-r--r-- | .ci/scripts/merge/apply-patches-by-label-private.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/.ci/scripts/merge/apply-patches-by-label-private.py b/.ci/scripts/merge/apply-patches-by-label-private.py new file mode 100644 index 000000000..11ec60010 --- /dev/null +++ b/.ci/scripts/merge/apply-patches-by-label-private.py | |||
| @@ -0,0 +1,41 @@ | |||
| 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> | ||
| 3 | |||
| 4 | import requests, sys, json, urllib3.request, shutil, subprocess, os, traceback | ||
| 5 | |||
| 6 | org = os.getenv("PrivateMergeOrg".upper(), "yuzu-emu") | ||
| 7 | repo = os.getenv("PrivateMergeRepo".upper(), "yuzu-private") | ||
| 8 | tagline = os.getenv("MergeTaglinePrivate".upper(), "") | ||
| 9 | user = sys.argv[1] | ||
| 10 | |||
| 11 | http = urllib3.PoolManager() | ||
| 12 | dl_list = {} | ||
| 13 | |||
| 14 | 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 | response = requests.get(url) | ||
| 17 | if (response.ok): | ||
| 18 | j = json.loads(response.content) | ||
| 19 | for tg in j['value']: | ||
| 20 | if (tg['name'] == sys.argv[2]): | ||
| 21 | return True | ||
| 22 | return False | ||
| 23 | |||
| 24 | try: | ||
| 25 | url = 'https://%sdev.azure.com/%s/%s/_apis/git/pullrequests?api-version=5.1' % (user, org, repo) | ||
| 26 | response = requests.get(url) | ||
| 27 | if (response.ok): | ||
| 28 | j = json.loads(response.content) | ||
| 29 | for pr in j["value"]: | ||
| 30 | repo_id = pr['repository']['id'] | ||
| 31 | pr_id = pr['pullRequestId'] | ||
| 32 | if (check_individual(repo_id, pr_id)): | ||
| 33 | pn = pr_id | ||
| 34 | ref = pr['sourceRefName'] | ||
| 35 | print("Matched PR# %s" % pn) | ||
| 36 | print(subprocess.check_output(["git", "fetch", "https://%sdev.azure.com/%s/_git/%s" % (user, org, repo), ref, "-f"])) | ||
| 37 | print(subprocess.check_output(["git", "merge", "--squash", 'origin/' + ref.replace('refs/heads/','')])) | ||
| 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) | ||