61ddb1aa07
* build: bump pylint to 2.17 Xref: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5062345 * fix pylint consider-using-f-string warnings pt 1: use flynt for automated fixes * fix pylint consider-using-f-string warnings pt 2: manual fixes * fix pylint consider-using-with warnings * fix pylint line-too-long warnings * fix pylint unspecified-encoding warnings * fix py lint consider-using-generator warning * fixup! fix pylint unspecified-encoding warnings * fix pylint line-too-long warnings
45 lines
1 KiB
Python
Executable file
45 lines
1 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
import warnings
|
|
|
|
from lib import git
|
|
from lib.patches import patch_from_dir
|
|
|
|
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):
|
|
warnings.warn(f'repo not found: {repo}')
|
|
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)
|
|
|
|
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()
|
|
|
|
|
|
def main():
|
|
for config_json in parse_args().config:
|
|
apply_config(json.load(config_json))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|