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
|
2024-02-08 18:47:59 +00:00
|
|
|
import warnings
|
2020-04-08 15:59:14 +00:00
|
|
|
|
|
|
|
from lib import git
|
|
|
|
|
|
|
|
|
2024-02-08 18:47:59 +00:00
|
|
|
def export_patches(target, dry_run):
|
|
|
|
repo = target.get('repo')
|
|
|
|
if not os.path.exists(repo):
|
|
|
|
warnings.warn('repo not found: %s' % repo)
|
|
|
|
return
|
|
|
|
git.export_patches(
|
|
|
|
dry_run=dry_run,
|
|
|
|
grep=target.get('grep'),
|
|
|
|
out_dir=target.get('patch_dir'),
|
|
|
|
repo=repo
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def export_config(config, dry_run):
|
|
|
|
for target in config:
|
|
|
|
export_patches(target, 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:
|
2024-02-08 18:47:59 +00:00
|
|
|
export_config(json.load(config_json), dry_run)
|
2020-04-08 15:59:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|