export_all_patches.py 894 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python3
  2. import argparse
  3. import json
  4. import os
  5. from lib import git
  6. def export_patches(dirs, dry_run):
  7. for patch_dir, repo in dirs.items():
  8. if os.path.exists(repo):
  9. git.export_patches(repo=repo, out_dir=patch_dir, dry_run=dry_run)
  10. def parse_args():
  11. parser = argparse.ArgumentParser(description='Export Electron patches')
  12. parser.add_argument('config', nargs='+',
  13. type=argparse.FileType('r'),
  14. help='patches\' config(s) in the JSON format')
  15. parser.add_argument("-d", "--dry-run",
  16. help="Checks whether the exported patches need to be updated.",
  17. default=False, action='store_true')
  18. return parser.parse_args()
  19. def main():
  20. configs = parse_args().config
  21. dry_run = parse_args().dry_run
  22. for config_json in configs:
  23. export_patches(json.load(config_json), dry_run)
  24. if __name__ == '__main__':
  25. main()