apply-patches-by-label.py 1.1 KB

123456789101112131415161718192021222324252627282930
  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. import requests, sys, json, urllib3.request, shutil, subprocess, os
  4. tagline = sys.argv[2]
  5. http = urllib3.PoolManager()
  6. dl_list = {}
  7. def check_individual(labels):
  8. for label in labels:
  9. if (label["name"] == sys.argv[1]):
  10. return True
  11. return False
  12. try:
  13. url = 'https://api.github.com/repos/yuzu-emu/yuzu/pulls'
  14. response = requests.get(url)
  15. if (response.ok):
  16. j = json.loads(response.content)
  17. for pr in j:
  18. if (check_individual(pr["labels"])):
  19. pn = pr["number"]
  20. print("Matched PR# %s" % pn)
  21. print(subprocess.check_output(["git", "fetch", "https://github.com/yuzu-emu/yuzu.git", "pull/%s/head:pr-%s" % (pn, pn), "-f"]))
  22. print(subprocess.check_output(["git", "merge", "--squash", "pr-%s" % pn]))
  23. print(subprocess.check_output(["git", "commit", "-m\"Merge %s PR %s\"" % (tagline, pn)]))
  24. except:
  25. sys.exit(-1)