Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-pre-commit for openSUSE:Factory checked in at 2022-03-26 22:32:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pre-commit (Old) and /work/SRC/openSUSE:Factory/.python-pre-commit.new.1900 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pre-commit" Sat Mar 26 22:32:14 2022 rev:8 rq:965080 version:2.17.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pre-commit/python-pre-commit.changes 2022-01-11 21:24:02.097159935 +0100 +++ /work/SRC/openSUSE:Factory/.python-pre-commit.new.1900/python-pre-commit.changes 2022-03-26 22:32:40.182085382 +0100 @@ -1,0 +2,16 @@ +Sat Mar 26 19:25:34 UTC 2022 - Dirk M??ller <dmuel...@suse.com> + +- update to 2.17.0: + - add warnings for regexes containing `[\\/]`. + - upgrade supported ruby versions. + - allow `language: conda` to use `mamba` or `micromamba` via + `PRE_COMMIT_USE_MAMBA=1` or `PRE_COMMIT_USE_MICROMAMBA=1` respectively. + - display `git --version` in error report. + - add `language: lua` as a supported language. + - temporarily add `setuptools` to the zipapp. + - use `go install` instead of `go get` for go 1.18+ support. + - fix `language: r` with a local renv and `RENV_PROJECT` set. + - forbid overriding `entry` in `language: meta` hooks which breaks them. + - always use `#!/bin/sh` on windows for hook script. + +------------------------------------------------------------------- Old: ---- pre_commit-2.16.0.tar.gz New: ---- pre_commit-2.17.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pre-commit.spec ++++++ --- /var/tmp/diff_new_pack.l2leeE/_old 2022-03-26 22:32:40.718086116 +0100 +++ /var/tmp/diff_new_pack.l2leeE/_new 2022-03-26 22:32:40.722086122 +0100 @@ -19,7 +19,7 @@ %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pre-commit -Version: 2.16.0 +Version: 2.17.0 Release: 0 Summary: Multi-language pre-commit hooks License: MIT @@ -27,6 +27,8 @@ Source: https://github.com/pre-commit/pre-commit/archive/v%{version}.tar.gz#/pre_commit-%{version}.tar.gz BuildRequires: %{python_module setuptools} BuildRequires: fdupes +BuildRequires: lua54-devel +BuildRequires: lua54-luarocks BuildRequires: python-rpm-macros Requires: python-PyYAML >= 5.1 Requires: python-cfgv >= 2.0.0 @@ -91,6 +93,8 @@ EXCLUDED_TESTS="$EXCLUDED_TESTS or test_local_rust_additional_dependencies or test_installed_from_venv" EXCLUDED_TESTS="$EXCLUDED_TESTS or conda or test_perl_hook or test_local_perl_additional_dependencies" EXCLUDED_TESTS="$EXCLUDED_TESTS or dart or dotnet or r_ or node or ruby" +EXCLUDED_TESTS="$EXCLUDED_TESTS or test_local_lua_additional_dependencies" + git init . %pytest -k "not ($EXCLUDED_TESTS)" ++++++ pre_commit-2.16.0.tar.gz -> pre_commit-2.17.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/.pre-commit-config.yaml new/pre-commit-2.17.0/.pre-commit-config.yaml --- old/pre-commit-2.16.0/.pre-commit-config.yaml 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/.pre-commit-config.yaml 2022-01-18 18:59:39.000000000 +0100 @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.1.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -17,15 +17,15 @@ - id: flake8 additional_dependencies: [flake8-typing-imports==1.10.0] - repo: https://github.com/pre-commit/mirrors-autopep8 - rev: v1.5.7 + rev: v1.6.0 hooks: - id: autopep8 - repo: https://github.com/pre-commit/pre-commit - rev: v2.16.0 + rev: v2.17.0 hooks: - id: validate_manifest - repo: https://github.com/asottile/pyupgrade - rev: v2.29.1 + rev: v2.31.0 hooks: - id: pyupgrade args: [--py36-plus] @@ -44,7 +44,7 @@ hooks: - id: setup-cfg-fmt - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.910-1 + rev: v0.931 hooks: - id: mypy additional_dependencies: [types-all] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/CHANGELOG.md new/pre-commit-2.17.0/CHANGELOG.md --- old/pre-commit-2.16.0/CHANGELOG.md 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/CHANGELOG.md 2022-01-18 18:59:39.000000000 +0100 @@ -1,3 +1,36 @@ +2.17.0 - 2022-01-18 +=================== + +### Features +- add warnings for regexes containing `[\\/]`. + - #2151 issue by @sanjioh. + - #2154 PR by @kuviokelluja. +- upgrade supported ruby versions. + - #2205 PR by @jalessio. +- allow `language: conda` to use `mamba` or `micromamba` via + `PRE_COMMIT_USE_MAMBA=1` or `PRE_COMMIT_USE_MICROMAMBA=1` respectively. + - #2204 issue by @janjagusch. + - #2207 PR by @xhochy. +- display `git --version` in error report. + - #2210 PR by @asottile. +- add `language: lua` as a supported language. + - #2158 PR by @mblayman. + +### Fixes +- temporarily add `setuptools` to the zipapp. + - #2122 issue by @andreoliwa. + - a737d5f commit by @asottile. +- use `go install` instead of `go get` for go 1.18+ support. + - #2161 PR by @schmir. +- fix `language: r` with a local renv and `RENV_PROJECT` set. + - #2170 PR by @lorenzwalthert. +- forbid overriding `entry` in `language: meta` hooks which breaks them. + - #2180 issue by @DanKaplanSES. + - #2181 PR by @asottile. +- always use `#!/bin/sh` on windows for hook script. + - #2182 issue by @hushigome-visco. + - #2187 PR by @asottile. + 2.16.0 - 2021-11-30 =================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/azure-pipelines.yml new/pre-commit-2.17.0/azure-pipelines.yml --- old/pre-commit-2.16.0/azure-pipelines.yml 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/azure-pipelines.yml 2022-01-18 18:59:39.000000000 +0100 @@ -42,6 +42,8 @@ displayName: install coursier - bash: testing/get-dart.sh displayName: install dart + - bash: testing/get-lua.sh + displayName: install lua - bash: testing/get-swift.sh displayName: install swift - bash: testing/get-r.sh @@ -56,6 +58,8 @@ displayName: install coursier - bash: testing/get-dart.sh displayName: install dart + - bash: testing/get-lua.sh + displayName: install lua - bash: testing/get-swift.sh displayName: install swift - bash: testing/get-r.sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/clientlib.py new/pre-commit-2.17.0/pre_commit/clientlib.py --- old/pre-commit-2.16.0/pre_commit/clientlib.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/clientlib.py 2022-01-18 18:59:39.000000000 +0100 @@ -144,18 +144,13 @@ f"regex, not a glob -- matching '/*' probably isn't what you " f'want here', ) - if r'[\/]' in dct.get(self.key, ''): - logger.warning( - fr'pre-commit normalizes slashes in the {self.key!r} field ' - fr'in hook {dct.get("id")!r} to forward slashes, so you ' - fr'can use / instead of [\/]', - ) - if r'[/\\]' in dct.get(self.key, ''): - logger.warning( - fr'pre-commit normalizes slashes in the {self.key!r} field ' - fr'in hook {dct.get("id")!r} to forward slashes, so you ' - fr'can use / instead of [/\\]', - ) + for fwd_slash_re in (r'[\\/]', r'[\/]', r'[/\\]'): + if fwd_slash_re in dct.get(self.key, ''): + logger.warning( + fr'pre-commit normalizes slashes in the {self.key!r} ' + fr'field in hook {dct.get("id")!r} to forward slashes, ' + fr'so you can use / instead of {fwd_slash_re}', + ) class OptionalSensibleRegexAtTop(cfgv.OptionalNoDefault): @@ -167,18 +162,13 @@ f'The top-level {self.key!r} field is a regex, not a glob -- ' f"matching '/*' probably isn't what you want here", ) - if r'[\/]' in dct.get(self.key, ''): - logger.warning( - fr'pre-commit normalizes the slashes in the top-level ' - fr'{self.key!r} field to forward slashes, so you can use / ' - fr'instead of [\/]', - ) - if r'[/\\]' in dct.get(self.key, ''): - logger.warning( - fr'pre-commit normalizes the slashes in the top-level ' - fr'{self.key!r} field to forward slashes, so you can use / ' - fr'instead of [/\\]', - ) + for fwd_slash_re in (r'[\\/]', r'[\/]', r'[/\\]'): + if fwd_slash_re in dct.get(self.key, ''): + logger.warning( + fr'pre-commit normalizes the slashes in the top-level ' + fr'{self.key!r} field to forward slashes, so you ' + fr'can use / instead of {fwd_slash_re}', + ) class MigrateShaToRev: @@ -261,12 +251,21 @@ ), ) + +class NotAllowed(cfgv.OptionalNoDefault): + def check(self, dct: Dict[str, Any]) -> None: + if self.key in dct: + raise cfgv.ValidationError(f'{self.key!r} cannot be overridden') + + META_HOOK_DICT = cfgv.Map( 'Hook', 'id', cfgv.Required('id', cfgv.check_string), cfgv.Required('id', cfgv.check_one_of(tuple(k for k, _ in _meta))), # language must be system cfgv.Optional('language', cfgv.check_one_of({'system'}), 'system'), + # entry cannot be overridden + NotAllowed('entry', cfgv.check_any), *( # default to the hook definition for the meta hooks cfgv.ConditionalOptional(key, cfgv.check_any, value, 'id', hook_id) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/commands/install_uninstall.py new/pre-commit-2.17.0/pre_commit/commands/install_uninstall.py --- old/pre-commit-2.16.0/pre_commit/commands/install_uninstall.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/commands/install_uninstall.py 2022-01-18 18:59:39.000000000 +0100 @@ -1,4 +1,3 @@ -import itertools import logging import os.path import shlex @@ -31,10 +30,6 @@ CURRENT_HASH = b'138fd403232d2ddd5efb44317e38bf03' TEMPLATE_START = '# start templated\n' TEMPLATE_END = '# end templated\n' -# Homebrew/homebrew-core#35825: be more timid about appropriate `PATH` -# #1312 os.defpath is too restrictive on BSD -POSIX_SEARCH_PATH = ('/usr/local/bin', '/usr/bin', '/bin') -SYS_EXE = os.path.basename(os.path.realpath(sys.executable)) def _hook_paths( @@ -54,26 +49,6 @@ return any(h in contents for h in (CURRENT_HASH,) + PRIOR_HASHES) -def shebang() -> str: - if sys.platform == 'win32': - py, _ = os.path.splitext(SYS_EXE) - else: - exe_choices = [ - f'python{sys.version_info[0]}.{sys.version_info[1]}', - f'python{sys.version_info[0]}', - ] - # avoid searching for bare `python` as it's likely to be python 2 - if SYS_EXE != 'python': - exe_choices.append(SYS_EXE) - for path, exe in itertools.product(POSIX_SEARCH_PATH, exe_choices): - if os.access(os.path.join(path, exe), os.X_OK): - py = exe - break - else: - py = SYS_EXE - return f'#!/usr/bin/env {py}' - - def _install_hook_script( config_file: str, hook_type: str, @@ -107,6 +82,13 @@ before, rest = contents.split(TEMPLATE_START) _, after = rest.split(TEMPLATE_END) + # on windows always use `/bin/sh` since `bash` might not be on PATH + # though we use bash-specific features `sh` on windows is actually + # bash in "POSIXLY_CORRECT" mode which still supports the features we + # use: subshells / arrays + if sys.platform == 'win32': # pragma: win32 cover + hook_file.write('#!/bin/sh\n') + hook_file.write(before + TEMPLATE_START) hook_file.write(f'INSTALL_PYTHON={shlex.quote(sys.executable)}\n') # TODO: python3.8+: shlex.join diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/commands/run.py new/pre-commit-2.17.0/pre_commit/commands/run.py --- old/pre-commit-2.16.0/pre_commit/commands/run.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/commands/run.py 2022-01-18 18:59:39.000000000 +0100 @@ -275,7 +275,6 @@ hooks: Sequence[Hook], skips: Set[str], args: argparse.Namespace, - environ: MutableMapping[str, str], ) -> int: """Actually run the hooks.""" cols = _compute_cols(hooks) @@ -416,7 +415,7 @@ to_install = [hook for hook in hooks if hook.id not in skips] install_hook_envs(to_install, store) - return _run_hooks(config, hooks, skips, args, environ) + return _run_hooks(config, hooks, skips, args) # https://github.com/python/mypy/issues/7726 raise AssertionError('unreachable') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/error_handler.py new/pre-commit-2.17.0/pre_commit/error_handler.py --- old/pre-commit-2.16.0/pre_commit/error_handler.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/error_handler.py 2022-01-18 18:59:39.000000000 +0100 @@ -9,6 +9,7 @@ from pre_commit import output from pre_commit.errors import FatalError from pre_commit.store import Store +from pre_commit.util import cmd_output_b from pre_commit.util import force_bytes @@ -21,6 +22,9 @@ error_msg = f'{msg}: {type(exc).__name__}: '.encode() + force_bytes(exc) output.write_line_b(error_msg) + _, git_version_b, _ = cmd_output_b('git', '--version', retcode=None) + git_version = git_version_b.decode(errors='backslashreplace').rstrip() + storedir = Store().directory log_path = os.path.join(storedir, 'pre-commit.log') with contextlib.ExitStack() as ctx: @@ -38,6 +42,7 @@ _log_line() _log_line('```') _log_line(f'pre-commit version: {C.VERSION}') + _log_line(f'git --version: {git_version}') _log_line('sys.version:') for line in sys.version.splitlines(): _log_line(f' {line}') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/languages/all.py new/pre-commit-2.17.0/pre_commit/languages/all.py --- old/pre-commit-2.16.0/pre_commit/languages/all.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/languages/all.py 2022-01-18 18:59:39.000000000 +0100 @@ -13,6 +13,7 @@ from pre_commit.languages import dotnet from pre_commit.languages import fail from pre_commit.languages import golang +from pre_commit.languages import lua from pre_commit.languages import node from pre_commit.languages import perl from pre_commit.languages import pygrep @@ -51,6 +52,7 @@ 'dotnet': Language(name='dotnet', ENVIRONMENT_DIR=dotnet.ENVIRONMENT_DIR, get_default_version=dotnet.get_default_version, healthy=dotnet.healthy, install_environment=dotnet.install_environment, run_hook=dotnet.run_hook), # noqa: E501 'fail': Language(name='fail', ENVIRONMENT_DIR=fail.ENVIRONMENT_DIR, get_default_version=fail.get_default_version, healthy=fail.healthy, install_environment=fail.install_environment, run_hook=fail.run_hook), # noqa: E501 'golang': Language(name='golang', ENVIRONMENT_DIR=golang.ENVIRONMENT_DIR, get_default_version=golang.get_default_version, healthy=golang.healthy, install_environment=golang.install_environment, run_hook=golang.run_hook), # noqa: E501 + 'lua': Language(name='lua', ENVIRONMENT_DIR=lua.ENVIRONMENT_DIR, get_default_version=lua.get_default_version, healthy=lua.healthy, install_environment=lua.install_environment, run_hook=lua.run_hook), # noqa: E501 'node': Language(name='node', ENVIRONMENT_DIR=node.ENVIRONMENT_DIR, get_default_version=node.get_default_version, healthy=node.healthy, install_environment=node.install_environment, run_hook=node.run_hook), # noqa: E501 'perl': Language(name='perl', ENVIRONMENT_DIR=perl.ENVIRONMENT_DIR, get_default_version=perl.get_default_version, healthy=perl.healthy, install_environment=perl.install_environment, run_hook=perl.run_hook), # noqa: E501 'pygrep': Language(name='pygrep', ENVIRONMENT_DIR=pygrep.ENVIRONMENT_DIR, get_default_version=pygrep.get_default_version, healthy=pygrep.healthy, install_environment=pygrep.install_environment, run_hook=pygrep.run_hook), # noqa: E501 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/languages/conda.py new/pre-commit-2.17.0/pre_commit/languages/conda.py --- old/pre-commit-2.16.0/pre_commit/languages/conda.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/languages/conda.py 2022-01-18 18:59:39.000000000 +0100 @@ -50,6 +50,15 @@ yield +def _conda_exe() -> str: + if os.environ.get('PRE_COMMIT_USE_MICROMAMBA'): + return 'micromamba' + elif os.environ.get('PRE_COMMIT_USE_MAMBA'): + return 'mamba' + else: + return 'conda' + + def install_environment( prefix: Prefix, version: str, @@ -58,15 +67,17 @@ helpers.assert_version_default('conda', version) directory = helpers.environment_dir(ENVIRONMENT_DIR, version) + conda_exe = _conda_exe() + env_dir = prefix.path(directory) with clean_path_on_failure(env_dir): cmd_output_b( - 'conda', 'env', 'create', '-p', env_dir, '--file', + conda_exe, 'env', 'create', '-p', env_dir, '--file', 'environment.yml', cwd=prefix.prefix_dir, ) if additional_dependencies: cmd_output_b( - 'conda', 'install', '-p', env_dir, *additional_dependencies, + conda_exe, 'install', '-p', env_dir, *additional_dependencies, cwd=prefix.prefix_dir, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/languages/golang.py new/pre-commit-2.17.0/pre_commit/languages/golang.py --- old/pre-commit-2.16.0/pre_commit/languages/golang.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/languages/golang.py 2022-01-18 18:59:39.000000000 +0100 @@ -79,9 +79,11 @@ gopath = directory env = dict(os.environ, GOPATH=gopath) env.pop('GOBIN', None) - cmd_output_b('go', 'get', './...', cwd=repo_src_dir, env=env) + cmd_output_b('go', 'install', './...', cwd=repo_src_dir, env=env) for dependency in additional_dependencies: - cmd_output_b('go', 'get', dependency, cwd=repo_src_dir, env=env) + cmd_output_b( + 'go', 'install', dependency, cwd=repo_src_dir, env=env, + ) # Same some disk space, we don't need these after installation rmtree(prefix.path(directory, 'src')) pkgdir = prefix.path(directory, 'pkg') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/languages/lua.py new/pre-commit-2.17.0/pre_commit/languages/lua.py --- old/pre-commit-2.16.0/pre_commit/languages/lua.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/languages/lua.py 2022-01-18 18:59:39.000000000 +0100 @@ -0,0 +1,90 @@ +import contextlib +import os +import sys +from typing import Generator +from typing import Sequence +from typing import Tuple + +import pre_commit.constants as C +from pre_commit.envcontext import envcontext +from pre_commit.envcontext import PatchesT +from pre_commit.envcontext import Var +from pre_commit.hook import Hook +from pre_commit.languages import helpers +from pre_commit.prefix import Prefix +from pre_commit.util import clean_path_on_failure +from pre_commit.util import cmd_output + +ENVIRONMENT_DIR = 'lua_env' +get_default_version = helpers.basic_get_default_version +healthy = helpers.basic_healthy + + +def _get_lua_version() -> str: # pragma: win32 no cover + """Get the Lua version used in file paths.""" + _, stdout, _ = cmd_output('luarocks', 'config', '--lua-ver') + return stdout.strip() + + +def get_env_patch(d: str) -> PatchesT: # pragma: win32 no cover + version = _get_lua_version() + so_ext = 'dll' if sys.platform == 'win32' else 'so' + return ( + ('PATH', (os.path.join(d, 'bin'), os.pathsep, Var('PATH'))), + ( + 'LUA_PATH', ( + os.path.join(d, 'share', 'lua', version, '?.lua;'), + os.path.join(d, 'share', 'lua', version, '?', 'init.lua;;'), + ), + ), + ( + 'LUA_CPATH', + (os.path.join(d, 'lib', 'lua', version, f'?.{so_ext};;'),), + ), + ) + + +def _envdir(prefix: Prefix) -> str: # pragma: win32 no cover + directory = helpers.environment_dir(ENVIRONMENT_DIR, C.DEFAULT) + return prefix.path(directory) + + +@contextlib.contextmanager # pragma: win32 no cover +def in_env(prefix: Prefix) -> Generator[None, None, None]: + with envcontext(get_env_patch(_envdir(prefix))): + yield + + +def install_environment( + prefix: Prefix, + version: str, + additional_dependencies: Sequence[str], +) -> None: # pragma: win32 no cover + helpers.assert_version_default('lua', version) + + envdir = _envdir(prefix) + with clean_path_on_failure(envdir): + with in_env(prefix): + # luarocks doesn't bootstrap a tree prior to installing + # so ensure the directory exists. + os.makedirs(envdir, exist_ok=True) + + # Older luarocks (e.g., 2.4.2) expect the rockspec as an arg + for rockspec in prefix.star('.rockspec'): + make_cmd = ('luarocks', '--tree', envdir, 'make', rockspec) + helpers.run_setup_cmd(prefix, make_cmd) + + # luarocks can't install multiple packages at once + # so install them individually. + for dependency in additional_dependencies: + cmd = ('luarocks', '--tree', envdir, 'install', dependency) + helpers.run_setup_cmd(prefix, cmd) + + +def run_hook( + hook: Hook, + file_args: Sequence[str], + color: bool, +) -> Tuple[int, bytes]: # pragma: win32 no cover + with in_env(hook.prefix): + return helpers.run_xargs(hook, hook.cmd, file_args, color=color) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/languages/r.py new/pre-commit-2.17.0/pre_commit/languages/r.py --- old/pre-commit-2.16.0/pre_commit/languages/r.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/languages/r.py 2022-01-18 18:59:39.000000000 +0100 @@ -8,6 +8,7 @@ from pre_commit.envcontext import envcontext from pre_commit.envcontext import PatchesT +from pre_commit.envcontext import UNSET from pre_commit.hook import Hook from pre_commit.languages import helpers from pre_commit.prefix import Prefix @@ -23,6 +24,7 @@ def get_env_patch(venv: str) -> PatchesT: return ( ('R_PROFILE_USER', os.path.join(venv, 'activate.R')), + ('RENV_PROJECT', UNSET), ) @@ -55,6 +57,10 @@ return (path,) +def _rscript_exec() -> str: + return os.path.join(os.getenv('R_HOME', ''), 'Rscript') + + def _entry_validate(entry: Sequence[str]) -> None: """ Allowed entries: @@ -95,8 +101,9 @@ os.makedirs(env_dir, exist_ok=True) shutil.copy(prefix.path('renv.lock'), env_dir) shutil.copytree(prefix.path('renv'), os.path.join(env_dir, 'renv')) + cmd_output_b( - 'Rscript', '--vanilla', '-e', + _rscript_exec(), '--vanilla', '-e', f"""\ prefix_dir <- {prefix.prefix_dir!r} options( @@ -130,7 +137,7 @@ if additional_dependencies: with in_env(prefix, version): cmd_output_b( - 'Rscript', *RSCRIPT_OPTS, '-e', + _rscript_exec(), *RSCRIPT_OPTS, '-e', 'renv::install(commandArgs(trailingOnly = TRUE))', *additional_dependencies, cwd=env_dir, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/resources/empty_template_pre-commit-package-dev-1.rockspec new/pre-commit-2.17.0/pre_commit/resources/empty_template_pre-commit-package-dev-1.rockspec --- old/pre-commit-2.16.0/pre_commit/resources/empty_template_pre-commit-package-dev-1.rockspec 1970-01-01 01:00:00.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/resources/empty_template_pre-commit-package-dev-1.rockspec 2022-01-18 18:59:39.000000000 +0100 @@ -0,0 +1,12 @@ +package = "pre-commit-package" +version = "dev-1" + +source = { + url = "git+ssh://g...@github.com/pre-commit/pre-commit.git" +} +description = {} +dependencies = {} +build = { + type = "builtin", + modules = {}, +} Binary files old/pre-commit-2.16.0/pre_commit/resources/rbenv.tar.gz and new/pre-commit-2.17.0/pre_commit/resources/rbenv.tar.gz differ Binary files old/pre-commit-2.16.0/pre_commit/resources/ruby-build.tar.gz and new/pre-commit-2.17.0/pre_commit/resources/ruby-build.tar.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/pre_commit/store.py new/pre-commit-2.17.0/pre_commit/store.py --- old/pre-commit-2.16.0/pre_commit/store.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/pre_commit/store.py 2022-01-18 18:59:39.000000000 +0100 @@ -188,7 +188,8 @@ LOCAL_RESOURCES = ( 'Cargo.toml', 'main.go', 'go.mod', 'main.rs', '.npmignore', - 'package.json', 'pre_commit_placeholder_package.gemspec', 'setup.py', + 'package.json', 'pre-commit-package-dev-1.rockspec', + 'pre_commit_placeholder_package.gemspec', 'setup.py', 'environment.yml', 'Makefile.PL', 'pubspec.yaml', 'renv.lock', 'renv/activate.R', 'renv/LICENSE.renv', ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/requirements-dev.txt new/pre-commit-2.17.0/requirements-dev.txt --- old/pre-commit-2.16.0/requirements-dev.txt 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/requirements-dev.txt 2022-01-18 18:59:39.000000000 +0100 @@ -1,4 +1,4 @@ -covdefaults>=2.1 +covdefaults>=2.2 coverage distlib pytest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/setup.cfg new/pre-commit-2.17.0/setup.cfg --- old/pre-commit-2.16.0/setup.cfg 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/setup.cfg 2022-01-18 18:59:39.000000000 +0100 @@ -1,6 +1,6 @@ [metadata] name = pre_commit -version = 2.16.0 +version = 2.17.0 description = A framework for managing and maintaining multi-language pre-commit hooks. long_description = file: README.md long_description_content_type = text/markdown diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/gen-languages-all new/pre-commit-2.17.0/testing/gen-languages-all --- old/pre-commit-2.16.0/testing/gen-languages-all 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/testing/gen-languages-all 2022-01-18 18:59:39.000000000 +0100 @@ -3,7 +3,7 @@ LANGUAGES = [ 'conda', 'coursier', 'dart', 'docker', 'docker_image', 'dotnet', 'fail', - 'golang', 'node', 'perl', 'pygrep', 'python', 'r', 'ruby', 'rust', + 'golang', 'lua', 'node', 'perl', 'pygrep', 'python', 'r', 'ruby', 'rust', 'script', 'swift', 'system', ] FIELDS = [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/get-lua.sh new/pre-commit-2.17.0/testing/get-lua.sh --- old/pre-commit-2.16.0/testing/get-lua.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/pre-commit-2.17.0/testing/get-lua.sh 2022-01-18 18:59:39.000000000 +0100 @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Install the runtime and package manager. +sudo apt install lua5.3 liblua5.3-dev luarocks diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/make-archives new/pre-commit-2.17.0/testing/make-archives --- old/pre-commit-2.16.0/testing/make-archives 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/testing/make-archives 2022-01-18 18:59:39.000000000 +0100 @@ -15,8 +15,8 @@ REPOS = ( - ('rbenv', 'https://github.com/rbenv/rbenv', '585ed84'), - ('ruby-build', 'https://github.com/rbenv/ruby-build', 'e9fa4bf'), + ('rbenv', 'https://github.com/rbenv/rbenv', '38e1fbb'), + ('ruby-build', 'https://github.com/rbenv/ruby-build', '8663d2f'), ( 'ruby-download', 'https://github.com/garnieretienne/rvm-download', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/resources/docker_hooks_repo/Dockerfile new/pre-commit-2.17.0/testing/resources/docker_hooks_repo/Dockerfile --- old/pre-commit-2.16.0/testing/resources/docker_hooks_repo/Dockerfile 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/testing/resources/docker_hooks_repo/Dockerfile 2022-01-18 18:59:39.000000000 +0100 @@ -1,3 +1,3 @@ -FROM cogniteev/echo +FROM ubuntu:focal CMD ["echo", "This is overwritten by the .pre-commit-hooks.yaml 'entry'"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/resources/docker_image_hooks_repo/.pre-commit-hooks.yaml new/pre-commit-2.17.0/testing/resources/docker_image_hooks_repo/.pre-commit-hooks.yaml --- old/pre-commit-2.16.0/testing/resources/docker_image_hooks_repo/.pre-commit-hooks.yaml 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/testing/resources/docker_image_hooks_repo/.pre-commit-hooks.yaml 2022-01-18 18:59:39.000000000 +0100 @@ -1,8 +1,8 @@ - id: echo-entrypoint name: echo (via --entrypoint) language: docker_image - entry: --entrypoint echo cogniteev/echo + entry: --entrypoint echo ubuntu:focal - id: echo-cmd name: echo (via cmd) language: docker_image - entry: cogniteev/echo echo + entry: ubuntu:focal echo diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/resources/lua_repo/.pre-commit-hooks.yaml new/pre-commit-2.17.0/testing/resources/lua_repo/.pre-commit-hooks.yaml --- old/pre-commit-2.16.0/testing/resources/lua_repo/.pre-commit-hooks.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/pre-commit-2.17.0/testing/resources/lua_repo/.pre-commit-hooks.yaml 2022-01-18 18:59:39.000000000 +0100 @@ -0,0 +1,4 @@ +- id: hello-world-lua + name: hello world lua + entry: hello-world-lua + language: lua diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/resources/lua_repo/bin/hello-world-lua new/pre-commit-2.17.0/testing/resources/lua_repo/bin/hello-world-lua --- old/pre-commit-2.16.0/testing/resources/lua_repo/bin/hello-world-lua 1970-01-01 01:00:00.000000000 +0100 +++ new/pre-commit-2.17.0/testing/resources/lua_repo/bin/hello-world-lua 2022-01-18 18:59:39.000000000 +0100 @@ -0,0 +1,3 @@ +#!/usr/bin/env lua + +print('hello world') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/resources/lua_repo/hello-dev-1.rockspec new/pre-commit-2.17.0/testing/resources/lua_repo/hello-dev-1.rockspec --- old/pre-commit-2.16.0/testing/resources/lua_repo/hello-dev-1.rockspec 1970-01-01 01:00:00.000000000 +0100 +++ new/pre-commit-2.17.0/testing/resources/lua_repo/hello-dev-1.rockspec 2022-01-18 18:59:39.000000000 +0100 @@ -0,0 +1,15 @@ +package = "hello" +version = "dev-1" + +source = { + url = "git+ssh://g...@github.com/pre-commit/pre-commit.git" +} +description = {} +dependencies = {} +build = { + type = "builtin", + modules = {}, + install = { + bin = {"bin/hello-world-lua"} + }, +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/util.py new/pre-commit-2.17.0/testing/util.py --- old/pre-commit-2.16.0/testing/util.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/testing/util.py 2022-01-18 18:59:39.000000000 +0100 @@ -48,6 +48,10 @@ os.name == 'nt' or not docker_is_running(), reason="Docker isn't running or can't be accessed", ) +skipif_cant_run_lua = pytest.mark.skipif( + os.name == 'nt', + reason="lua isn't installed or can't be found", +) skipif_cant_run_swift = pytest.mark.skipif( parse_shebang.find_executable('swift') is None, reason="swift isn't installed or can't be found", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/testing/zipapp/make new/pre-commit-2.17.0/testing/zipapp/make --- old/pre-commit-2.16.0/testing/zipapp/make 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/testing/zipapp/make 2022-01-18 18:59:39.000000000 +0100 @@ -71,7 +71,7 @@ _msg('populating wheels...') _exit_if_retv( 'podman', 'run', '--rm', '--volume', f'{wheeldir}:/wheels:rw', IMG, - 'pip', 'wheel', f'pre_commit=={args.version}', + 'pip', 'wheel', f'pre_commit=={args.version}', 'setuptools', '--wheel-dir', '/wheels', ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/tests/clientlib_test.py new/pre-commit-2.17.0/tests/clientlib_test.py --- old/pre-commit-2.16.0/tests/clientlib_test.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/tests/clientlib_test.py 2022-01-18 18:59:39.000000000 +0100 @@ -265,6 +265,11 @@ r"pre-commit normalizes slashes in the 'files' field in hook " r"'flake8' to forward slashes, so you can use / instead of [/\\]", ), + ( + r'dir[\\/].*\.py', + r"pre-commit normalizes slashes in the 'files' field in hook " + r"'flake8' to forward slashes, so you can use / instead of [\\/]", + ), ), ) def test_validate_optional_sensible_regex_at_hook(caplog, regex, warning): @@ -295,6 +300,11 @@ r"pre-commit normalizes the slashes in the top-level 'files' " r'field to forward slashes, so you can use / instead of [/\\]', ), + ( + r'dir[\\/].*\.py', + r"pre-commit normalizes the slashes in the top-level 'files' " + r'field to forward slashes, so you can use / instead of [\\/]', + ), ), ) def test_validate_optional_sensible_regex_at_top_level(caplog, regex, warning): @@ -413,6 +423,13 @@ {'repo': 'meta', 'hooks': [{'id': 'identity', 'language': 'python'}]}, # name override must be string {'repo': 'meta', 'hooks': [{'id': 'identity', 'name': False}]}, + pytest.param( + { + 'repo': 'meta', + 'hooks': [{'id': 'identity', 'entry': 'echo hi'}], + }, + id='cannot override entry for meta hooks', + ), ), ) def test_meta_hook_invalid(config_repo): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/tests/commands/install_uninstall_test.py new/pre-commit-2.17.0/tests/commands/install_uninstall_test.py --- old/pre-commit-2.16.0/tests/commands/install_uninstall_test.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/tests/commands/install_uninstall_test.py 2022-01-18 18:59:39.000000000 +0100 @@ -1,19 +1,15 @@ import os.path import re -import sys -from unittest import mock import re_assert import pre_commit.constants as C from pre_commit import git -from pre_commit.commands import install_uninstall from pre_commit.commands.install_uninstall import CURRENT_HASH from pre_commit.commands.install_uninstall import install from pre_commit.commands.install_uninstall import install_hooks from pre_commit.commands.install_uninstall import is_our_script from pre_commit.commands.install_uninstall import PRIOR_HASHES -from pre_commit.commands.install_uninstall import shebang from pre_commit.commands.install_uninstall import uninstall from pre_commit.parse_shebang import find_executable from pre_commit.util import cmd_output @@ -43,43 +39,6 @@ assert is_our_script(f.strpath) -def patch_platform(platform): - return mock.patch.object(sys, 'platform', platform) - - -def patch_lookup_path(path): - return mock.patch.object(install_uninstall, 'POSIX_SEARCH_PATH', path) - - -def patch_sys_exe(exe): - return mock.patch.object(install_uninstall, 'SYS_EXE', exe) - - -def test_shebang_windows(): - with patch_platform('win32'), patch_sys_exe('python'): - assert shebang() == '#!/usr/bin/env python' - - -def test_shebang_windows_drop_ext(): - with patch_platform('win32'), patch_sys_exe('python.exe'): - assert shebang() == '#!/usr/bin/env python' - - -def test_shebang_posix_not_on_path(): - with patch_platform('posix'), patch_lookup_path(()): - with patch_sys_exe('python3.6'): - assert shebang() == '#!/usr/bin/env python3.6' - - -def test_shebang_posix_on_path(tmpdir): - exe = tmpdir.join(f'python{sys.version_info[0]}').ensure() - make_executable(exe) - - with patch_platform('posix'), patch_lookup_path((tmpdir.strpath,)): - with patch_sys_exe('python'): - assert shebang() == f'#!/usr/bin/env python{sys.version_info[0]}' - - def test_install_pre_commit(in_git_dir, store): assert not install(C.CONFIG_FILE, store, hook_types=['pre-commit']) assert os.access(in_git_dir.join('.git/hooks/pre-commit').strpath, os.X_OK) @@ -336,7 +295,7 @@ def _write_legacy_hook(path): os.makedirs(os.path.join(path, '.git/hooks'), exist_ok=True) with open(os.path.join(path, '.git/hooks/pre-commit'), 'w') as f: - f.write(f'{shebang()}\nprint("legacy hook")\n') + f.write('#!/usr/bin/env bash\necho legacy hook\n') make_executable(f.name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/tests/error_handler_test.py new/pre-commit-2.17.0/tests/error_handler_test.py --- old/pre-commit-2.16.0/tests/error_handler_test.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/tests/error_handler_test.py 2022-01-18 18:59:39.000000000 +0100 @@ -122,6 +122,7 @@ r'\n' r'```\n' r'pre-commit version: \d+\.\d+\.\d+\n' + r'git --version: git version .+\n' r'sys.version:\n' r'( .*\n)*' r'sys.executable: .*\n' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/tests/languages/conda_test.py new/pre-commit-2.17.0/tests/languages/conda_test.py --- old/pre-commit-2.16.0/tests/languages/conda_test.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pre-commit-2.17.0/tests/languages/conda_test.py 2022-01-18 18:59:39.000000000 +0100 @@ -0,0 +1,38 @@ +import pytest + +from pre_commit import envcontext +from pre_commit.languages.conda import _conda_exe + + +@pytest.mark.parametrize( + ('ctx', 'expected'), + ( + pytest.param( + ( + ('PRE_COMMIT_USE_MICROMAMBA', envcontext.UNSET), + ('PRE_COMMIT_USE_MAMBA', envcontext.UNSET), + ), + 'conda', + id='default', + ), + pytest.param( + ( + ('PRE_COMMIT_USE_MICROMAMBA', '1'), + ('PRE_COMMIT_USE_MAMBA', ''), + ), + 'micromamba', + id='default', + ), + pytest.param( + ( + ('PRE_COMMIT_USE_MICROMAMBA', ''), + ('PRE_COMMIT_USE_MAMBA', '1'), + ), + 'mamba', + id='default', + ), + ), +) +def test_conda_exe(ctx, expected): + with envcontext.envcontext(ctx): + assert _conda_exe() == expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/tests/languages/helpers_test.py new/pre-commit-2.17.0/tests/languages/helpers_test.py --- old/pre-commit-2.16.0/tests/languages/helpers_test.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/tests/languages/helpers_test.py 2022-01-18 18:59:39.000000000 +0100 @@ -72,8 +72,8 @@ def test_failed_setup_command_does_not_unicode_error(): script = ( 'import sys\n' - "getattr(sys.stderr, 'buffer', sys.stderr).write(b'\\x81\\xfe')\n" - 'exit(1)\n' + "sys.stderr.buffer.write(b'\\x81\\xfe')\n" + 'raise SystemExit(1)\n' ) # an assertion that this does not raise `UnicodeError` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pre-commit-2.16.0/tests/repository_test.py new/pre-commit-2.17.0/tests/repository_test.py --- old/pre-commit-2.16.0/tests/repository_test.py 2021-12-01 00:16:47.000000000 +0100 +++ new/pre-commit-2.17.0/tests/repository_test.py 2022-01-18 18:59:39.000000000 +0100 @@ -34,6 +34,7 @@ from testing.util import get_resource_path from testing.util import skipif_cant_run_coursier from testing.util import skipif_cant_run_docker +from testing.util import skipif_cant_run_lua from testing.util import skipif_cant_run_swift from testing.util import xfailif_windows @@ -1128,3 +1129,29 @@ 'using language `system` which does not install an environment. ' 'Perhaps you meant to use a specific language?' ) + + +@skipif_cant_run_lua # pragma: win32 no cover +def test_lua_hook(tempdir_factory, store): + _test_hook_repo( + tempdir_factory, store, 'lua_repo', + 'hello-world-lua', [], b'hello world\n', + ) + + +@skipif_cant_run_lua # pragma: win32 no cover +def test_local_lua_additional_dependencies(store): + config = { + 'repo': 'local', + 'hooks': [{ + 'id': 'local-lua', + 'name': 'local-lua', + 'entry': 'luacheck --version', + 'language': 'lua', + 'additional_dependencies': ['luacheck'], + }], + } + hook = _get_hook(config, store, 'local-lua') + ret, out = _hook_run(hook, (), color=False) + assert b'Luacheck' in out + assert ret == 0