 b253d52faf
			
		
	
	
	
	
	b253d52faf* build: make patches/config.json an array of objects This file was previously an object of patch_dir keys to repo values; Now is an array of objects containing `patch_dir` and `repo` properties. This makes other per-target properties (e.g. `grep`) possible. * build: include Note metadata when exporting patches * build: support keyword filtering in export_patches() * build: add optional `--grep` arg to git-export-patches script * build: update export_all_patches to understand new config file * fixup! build: update export_all_patches to understand new config file chore: make lint happy * fixup! build: make patches/config.json an array of objects chore: fix oops * refactor: remove support for the old file format There is more code using config.json than I thought, so the effort-to-reward of supporting the old format is not worth it. * build: update apply_all_patches to understand new config file * build: update lint.js to understand new config file * build: update patches-mtime-cache.py to understand new config file * fixup! build: update apply_all_patches to understand new config file fix: oops * fixup! build: update apply_all_patches to understand new config file fix minor syntax wart * fixup! build: support keyword filtering in export_patches() refactor: use idiomatic python * refactor: warn if config.json has an invalid repo
		
			
				
	
	
		
			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('repo not found: %s' % 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()
 |