2022-04-12 11:21:55 +00:00
|
|
|
#!/usr/bin/env python3
|
2020-04-08 15:59:14 +00:00
|
|
|
|
|
|
|
import argparse
|
|
|
|
import json
|
2022-08-25 16:39:16 +00:00
|
|
|
import os
|
2020-04-08 15:59:14 +00:00
|
|
|
|
|
|
|
from lib import git
|
|
|
|
|
|
|
|
|
2020-06-05 00:43:28 +00:00
|
|
|
def export_patches(dirs, dry_run):
|
2020-10-30 10:05:38 +00:00
|
|
|
for patch_dir, repo in dirs.items():
|
2022-08-25 16:39:16 +00:00
|
|
|
if os.path.exists(repo):
|
|
|
|
git.export_patches(repo=repo, out_dir=patch_dir, dry_run=dry_run)
|
2020-04-08 15:59:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser(description='Export Electron patches')
|
|
|
|
parser.add_argument('config', nargs='+',
|
|
|
|
type=argparse.FileType('r'),
|
|
|
|
help='patches\' config(s) in the JSON format')
|
2020-06-05 00:43:28 +00:00
|
|
|
parser.add_argument("-d", "--dry-run",
|
|
|
|
help="Checks whether the exported patches need to be updated.",
|
|
|
|
default=False, action='store_true')
|
2020-04-08 15:59:14 +00:00
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
configs = parse_args().config
|
2020-06-05 00:43:28 +00:00
|
|
|
dry_run = parse_args().dry_run
|
2020-04-08 15:59:14 +00:00
|
|
|
for config_json in configs:
|
2020-06-05 00:43:28 +00:00
|
|
|
export_patches(json.load(config_json), dry_run)
|
2020-04-08 15:59:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|