def main(argv: Optional[Sequence[str]] = None) -> int: parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) autofix_lib.assert_importable( 'setup_py_upgrade', install='setup-py-upgrade', ) autofix_lib.assert_importable('setup_cfg_fmt', install='setup-cfg-fmt') repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg='Migrate setup.py to setup.cfg declarative metadata', branch_name='setup-py-upgrade', ) autofix_lib.fix( repos, apply_fix=apply_fix, config=config, commit=commit, autofix_settings=autofix_settings, ) return 0
def main(argv: Sequence[str] | None = None) -> int: parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) autofix_lib.assert_importable('pre_commit', install='pre-commit') # pre-commit 0.16.3: autoupdate maintains formatting better # pre-commit 0.17.0: race conditions in pre-commit install fixed # pre-commit 1.0.0: migrate_config(...) is called for autoupdate # pre-commit 1.0.1: exit code fix # pre-commit 1.7.0: sha -> rev autofix_lib.require_version_gte('pre-commit', '1.7.0') repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg='Run pre-commit autoupdate', branch_name='pre-commit-autoupdate', ) with tmp_pre_commit_home(): autofix_lib.fix( repos, apply_fix=apply_fix, check_fix=check_fix, config=config, commit=commit, autofix_settings=autofix_settings, ) return 0
def main(argv: Optional[Sequence[str]] = None) -> int: parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) autofix_lib.assert_importable('pre_commit', install='pre-commit') # pre-commit 1.0.0: introduces migrate-config # pre-commit 1.0.1: exit code fix # pre-commit 1.7.0: sha -> rev autofix_lib.require_version_gte('pre-commit', '1.7.0') repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg='Ran pre-commit migrate-config.', branch_name='pre-commit-migrate-config', ) with tmp_pre_commit_home(): autofix_lib.fix( repos, apply_fix=apply_fix, check_fix=check_fix, config=config, commit=commit, autofix_settings=autofix_settings, ) return 0
def main(argv: Optional[Sequence[str]] = None) -> int: parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) autofix_lib.assert_importable('pre_commit', install='pre-commit') autofix_lib.require_version_gte('pre-commit', '1.7.0') repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg='Migrate to official pycqa/flake8 hooks repo', branch_name='pre-commit-flake8-migrate', ) with tmp_pre_commit_home(): autofix_lib.fix( repos, apply_fix=apply_fix, check_fix=check_fix, config=config, commit=commit, autofix_settings=autofix_settings, ) return 0
def main(argv: Sequence[str] | None = None) -> int: parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) autofix_lib.assert_importable('pre_commit', install='pre-commit') autofix_lib.require_version_gte('pre-commit', '1.7.0') repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg='Migrate from autopep8-wrapper to mirrors-autopep8', branch_name='pre-commit-autopep8-migrate', ) with tmp_pre_commit_home(): autofix_lib.fix( repos, apply_fix=apply_fix, check_fix=check_fix, config=config, commit=commit, autofix_settings=autofix_settings, ) return 0
def main(argv=None): parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg="Use and pin Black 20", branch_name="black20", ) autofix_lib.fix( repos, apply_fix=apply_fix, config=config, commit=commit, autofix_settings=autofix_settings, )
def main(argv=None): parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg='Update pre-commit cache directory.', branch_name='pre-commit-cache-dir', ) autofix_lib.fix( repos, apply_fix=apply_fix, config=config, commit=commit, autofix_settings=autofix_settings, )
def main(argv: Sequence[str] | None = None) -> int: parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg='Update azure-pipelines template repositories', branch_name='azure-pipelines-autoupdate', ) autofix_lib.fix( repos, apply_fix=apply_fix, config=config, commit=commit, autofix_settings=autofix_settings, ) return 0
def main(argv: Optional[Sequence[str]] = None) -> int: parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg="Add Apache 2 licences", branch_name="add-licence-apache2", ) autofix_lib.fix( repos, apply_fix=apply_fix, config=config, commit=commit, autofix_settings=autofix_settings, ) return 0
def main(argv: Optional[Sequence[str]] = None) -> int: parser = argparse.ArgumentParser() autofix_lib.add_fixer_args(parser) args = parser.parse_args(argv) repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg="Cleanup Apache 2 licence templates, add ASL2 if absent", branch_name="cleanup-licence", ) autofix_lib.fix( repos, apply_fix=apply_fix, config=config, commit=commit, autofix_settings=autofix_settings, ) return 0
def main(argv: Sequence[str] | None = None) -> int: parser = argparse.ArgumentParser( description='Interactively apply a manual change across repos.', usage='%(prog)s [options]', ) autofix_lib.add_fixer_args(parser) parser.add_argument( '--branch-name', default='all-repos-manual', help='override the autofixer branch name (default `%(default)s`).', ) parser.add_argument( '--commit-msg', required=True, help='set the autofixer commit message.', ) args = parser.parse_args(argv) # force interactive args.interactive = True repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=find_repos, msg=args.commit_msg, branch_name=args.branch_name, ) autofix_lib.fix( repos, apply_fix=autofix_lib.shell, config=config, commit=commit, autofix_settings=autofix_settings, ) return 0
def main(argv=None): parser = argparse.ArgumentParser( description=( 'Similar to a distributed ' '`git ls-files -z -- FILENAMES | xargs -0 sed -i EXPRESSION`.'), usage='%(prog)s [options] EXPRESSION FILENAMES', ) autofix_lib.add_fixer_args(parser) parser.add_argument( '-r', '--regexp-extended', action='store_true', help='use extended regular expressions in the script.', ) parser.add_argument( '--branch-name', default='all-repos-sed', help='override the autofixer branch name (default `%(default)s`).', ) parser.add_argument( '--commit-msg', help=( 'override the autofixer commit message. (default ' '`git ls-files -z -- FILENAMES | xargs -0 sed -i ... EXPRESSION`).' ), ) parser.add_argument( 'expression', help='sed program. For example: `s/hi/hello/g`.', ) parser.add_argument( 'filenames', help='filenames glob (passed to `git ls-files`).', ) args = parser.parse_args(argv) dash_r = ('-r', ) if args.regexp_extended else () sed_cmd = ('sed', '-i', *dash_r, args.expression) ls_files_cmd = ('git', 'ls-files', '-z', '--', args.filenames) msg = f'{_quote_cmd(ls_files_cmd)} | xargs -0 {_quote_cmd(sed_cmd)}' msg = args.commit_msg or msg repos, config, commit, autofix_settings = autofix_lib.from_cli( args, find_repos=functools.partial(find_repos, ls_files_cmd=ls_files_cmd), msg=msg, branch_name=args.branch_name, ) autofix_lib.fix( repos, apply_fix=functools.partial( apply_fix, ls_files_cmd=ls_files_cmd, sed_cmd=sed_cmd, ), config=config, commit=commit, autofix_settings=autofix_settings, )