apply-patches-by-label.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  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, traceback
  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. def do_page(page):
  13. url = 'https://api.github.com/repos/yuzu-emu/yuzu/pulls?page=%s' % page
  14. response = requests.get(url)
  15. if (response.ok):
  16. j = json.loads(response.content)
  17. if j == []:
  18. return
  19. for pr in j:
  20. if (check_individual(pr["labels"])):
  21. pn = pr["number"]
  22. print("Matched PR# %s" % pn)
  23. print(subprocess.check_output(["git", "fetch", "https://github.com/yuzu-emu/yuzu.git", "pull/%s/head:pr-%s" % (pn, pn), "-f", "--no-recurse-submodules"]))
  24. print(subprocess.check_output(["git", "merge", "--squash", "pr-%s" % pn]))
  25. print(subprocess.check_output(["git", "commit", "-m\"Merge %s PR %s\"" % (tagline, pn)]))
  26. try:
  27. for i in range(1,30):
  28. do_page(i)
  29. except:
  30. traceback.print_exc(file=sys.stdout)
  31. sys.exit(-1)