apply-patches-by-label.py 1.0 KB

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