2022-04-12 11:21:55 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-10-24 18:24:11 +00:00
|
|
|
|
2018-11-05 16:31:28 +00:00
|
|
|
import argparse
|
|
|
|
import json
|
2019-06-18 22:15:06 +00:00
|
|
|
import os
|
2024-02-08 18:47:59 +00:00
|
|
|
import warnings
|
2018-11-05 16:31:28 +00:00
|
|
|
|
2018-10-24 18:24:11 +00:00
|
|
|
from lib import git
|
|
|
|
from lib.patches import patch_from_dir
|
|
|
|
|
2024-02-08 18:47:59 +00:00
|
|
|
THREEWAY = "ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES" in os.environ
|
|
|
|
|
|
|
|
def apply_patches(target):
|
|
|
|
repo = target.get('repo')
|
|
|
|
if not os.path.exists(repo):
|
2024-03-21 13:48:23 +00:00
|
|
|
warnings.warn(f'repo not found: {repo}')
|
2024-02-08 18:47:59 +00:00
|
|
|
return
|
|
|
|
patch_dir = target.get('patch_dir')
|
|
|
|
git.import_patches(
|
|
|
|
committer_email="scripts@electron",
|
|
|
|
committer_name="Electron Scripts",
|
|
|
|
patch_data=patch_from_dir(patch_dir),
|
|
|
|
repo=repo,
|
|
|
|
threeway=THREEWAY,
|
|
|
|
)
|
|
|
|
|
|
|
|
def apply_config(config):
|
|
|
|
for target in config:
|
|
|
|
apply_patches(target)
|
2018-10-24 18:24:11 +00:00
|
|
|
|
2018-11-05 16:31:28 +00:00
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser(description='Apply Electron patches')
|
|
|
|
parser.add_argument('config', nargs='+',
|
|
|
|
type=argparse.FileType('r'),
|
|
|
|
help='patches\' config(s) in the JSON format')
|
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
2018-10-24 18:24:11 +00:00
|
|
|
def main():
|
2024-02-08 18:47:59 +00:00
|
|
|
for config_json in parse_args().config:
|
|
|
|
apply_config(json.load(config_json))
|
2018-10-24 18:24:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|