Hello community,
here is the log from the commit of package python-pre-commit for
openSUSE:Factory checked in at 2020-05-04 18:40:27
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pre-commit (Old)
and /work/SRC/openSUSE:Factory/.python-pre-commit.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pre-commit"
Mon May 4 18:40:27 2020 rev:3 rq:799932 version:2.3.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pre-commit/python-pre-commit.changes
2020-03-19 19:52:36.484264074 +0100
+++
/work/SRC/openSUSE:Factory/.python-pre-commit.new.2738/python-pre-commit.changes
2020-05-04 18:41:23.893160021 +0200
@@ -1,0 +2,25 @@
+Sat May 2 21:01:03 UTC 2020 - Arun Persaud <[email protected]>
+
+- specfile:
+ * be more specific in %files section
+
+- update to version 2.3.0:
+ * Features
+ + Calculate character width using `east_asian_width` - #1378 PR by
+ @sophgn.
+ + Use `language_version: system` by default for `node` hooks if
+ `node` / `npm` are globally installed. - #1388 PR by @asottile.
+ * Fixes
+ + No longer use a hard-coded user id for docker hooks on windows -
+ #1371 PR by @killuazhu.
+ + Fix colors on windows during `git commit` - #1381 issue by
+ @Cielquan. - #1382 PR by @asottile.
+ + Produce readable error message for incorrect argument count to
+ `hook-impl` - #1394 issue by @pip9ball. - #1395 PR by
+ @asottile.
+ + Fix installations which involve an upgrade of `pip` on windows -
+ #1398 issue by @xiaohuazi123. - #1399 PR by @asottile.
+ + Preserve line endings in `pre-commit autoupdate` - #1402 PR by
+ @utek.
+
+-------------------------------------------------------------------
Old:
----
pre_commit-2.2.0.tar.gz
New:
----
pre_commit-2.3.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pre-commit.spec ++++++
--- /var/tmp/diff_new_pack.VhX2Oq/_old 2020-05-04 18:41:25.861164080 +0200
+++ /var/tmp/diff_new_pack.VhX2Oq/_new 2020-05-04 18:41:25.865164088 +0200
@@ -18,9 +18,8 @@
%define skip_python2 1
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-%define skip_python2 1
Name: python-pre-commit
-Version: 2.2.0
+Version: 2.3.0
Release: 0
Summary: Multi-language pre-commit hooks
License: MIT
@@ -91,6 +90,7 @@
%{_bindir}/pre-commit-validate-manifest
%{_bindir}/pre-commit
%{_bindir}/pre-commit-validate-config
-%{python_sitelib}/*
+%{python_sitelib}/pre_commit
+%{python_sitelib}/pre_commit-%{version}-py*.egg-info
%changelog
++++++ pre_commit-2.2.0.tar.gz -> pre_commit-2.3.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/.pre-commit-config.yaml
new/pre-commit-2.3.0/.pre-commit-config.yaml
--- old/pre-commit-2.2.0/.pre-commit-config.yaml 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/.pre-commit-config.yaml 2020-04-22
23:16:23.000000000 +0200
@@ -17,34 +17,34 @@
- id: flake8
additional_dependencies: [flake8-typing-imports==1.6.0]
- repo: https://github.com/pre-commit/mirrors-autopep8
- rev: v1.5
+ rev: v1.5.1
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/pre-commit
- rev: v2.1.1
+ rev: v2.2.0
hooks:
- id: validate_manifest
- repo: https://github.com/asottile/pyupgrade
- rev: v2.0.1
+ rev: v2.1.0
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/asottile/reorder_python_imports
- rev: v1.9.0
+ rev: v2.1.0
hooks:
- id: reorder-python-imports
args: [--py3-plus]
- repo: https://github.com/asottile/add-trailing-comma
- rev: v1.5.0
+ rev: v2.0.1
hooks:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/asottile/setup-cfg-fmt
- rev: v1.6.0
+ rev: v1.8.2
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/pre-commit/mirrors-mypy
- rev: v0.761
+ rev: v0.770
hooks:
- id: mypy
exclude: ^testing/resources/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/CHANGELOG.md
new/pre-commit-2.3.0/CHANGELOG.md
--- old/pre-commit-2.2.0/CHANGELOG.md 2020-03-12 20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/CHANGELOG.md 2020-04-22 23:16:23.000000000 +0200
@@ -1,9 +1,34 @@
+2.3.0 - 2020-04-22
+==================
+
+### Features
+- Calculate character width using `east_asian_width`
+ - #1378 PR by @sophgn.
+- Use `language_version: system` by default for `node` hooks if `node` / `npm`
+ are globally installed.
+ - #1388 PR by @asottile.
+
+### Fixes
+- No longer use a hard-coded user id for docker hooks on windows
+ - #1371 PR by @killuazhu.
+- Fix colors on windows during `git commit`
+ - #1381 issue by @Cielquan.
+ - #1382 PR by @asottile.
+- Produce readable error message for incorrect argument count to `hook-impl`
+ - #1394 issue by @pip9ball.
+ - #1395 PR by @asottile.
+- Fix installations which involve an upgrade of `pip` on windows
+ - #1398 issue by @xiaohuazi123.
+ - #1399 PR by @asottile.
+- Preserve line endings in `pre-commit autoupdate`
+ - #1402 PR by @utek.
+
2.2.0 - 2020-03-12
==================
### Features
- Add support for the `post-checkout` hook
- - #1210 issue by @domenkozar.
+ - #1120 issue by @domenkozar.
- #1339 PR by @andrewhare.
- Add more readable `--from-ref` / `--to-ref` aliases for `--source` /
`--origin`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/pre_commit/color.py
new/pre-commit-2.3.0/pre_commit/color.py
--- old/pre-commit-2.2.0/pre_commit/color.py 2020-03-12 20:37:15.000000000
+0100
+++ new/pre-commit-2.3.0/pre_commit/color.py 2020-04-22 23:16:23.000000000
+0200
@@ -11,7 +11,7 @@
from ctypes.wintypes import DWORD
from ctypes.wintypes import HANDLE
- STD_OUTPUT_HANDLE = -11
+ STD_ERROR_HANDLE = -12
ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
def bool_errcheck(result, func, args):
@@ -40,9 +40,9 @@
#
# More info on the escape sequences supported:
#
https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx
- stdout = GetStdHandle(STD_OUTPUT_HANDLE)
- flags = GetConsoleMode(stdout)
- SetConsoleMode(stdout, flags | ENABLE_VIRTUAL_TERMINAL_PROCESSING)
+ stderr = GetStdHandle(STD_ERROR_HANDLE)
+ flags = GetConsoleMode(stderr)
+ SetConsoleMode(stderr, flags | ENABLE_VIRTUAL_TERMINAL_PROCESSING)
try:
_enable()
@@ -90,7 +90,7 @@
return (
setting == 'always' or (
setting == 'auto' and
- sys.stdout.isatty() and
+ sys.stderr.isatty() and
terminal_supports_color and
os.getenv('TERM') != 'dumb'
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/pre_commit/commands/autoupdate.py
new/pre-commit-2.3.0/pre_commit/commands/autoupdate.py
--- old/pre-commit-2.2.0/pre_commit/commands/autoupdate.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/pre_commit/commands/autoupdate.py 2020-04-22
23:16:23.000000000 +0200
@@ -93,7 +93,7 @@
retry: bool = False,
) -> Tuple[List[str], List[int]]:
"""detect `rev:` lines or reformat the file"""
- with open(path) as f:
+ with open(path, newline='') as f:
original = f.read()
lines = original.splitlines(True)
@@ -126,7 +126,7 @@
comment = match[4]
lines[idx] = f'{match[1]}rev:{match[2]}{new_rev}{comment}{match[5]}'
- with open(path, 'w') as f:
+ with open(path, 'w', newline='') as f:
f.write(''.join(lines))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/pre_commit/commands/hook_impl.py
new/pre-commit-2.3.0/pre_commit/commands/hook_impl.py
--- old/pre-commit-2.2.0/pre_commit/commands/hook_impl.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/pre_commit/commands/hook_impl.py 2020-04-22
23:16:23.000000000 +0200
@@ -147,15 +147,44 @@
return None
+_EXPECTED_ARG_LENGTH_BY_HOOK = {
+ 'commit-msg': 1,
+ 'post-checkout': 3,
+ 'pre-commit': 0,
+ 'pre-merge-commit': 0,
+ 'pre-push': 2,
+}
+
+
+def _check_args_length(hook_type: str, args: Sequence[str]) -> None:
+ if hook_type == 'prepare-commit-msg':
+ if len(args) < 1 or len(args) > 3:
+ raise SystemExit(
+ f'hook-impl for {hook_type} expected 1, 2, or 3 arguments '
+ f'but got {len(args)}: {args}',
+ )
+ elif hook_type in _EXPECTED_ARG_LENGTH_BY_HOOK:
+ expected = _EXPECTED_ARG_LENGTH_BY_HOOK[hook_type]
+ if len(args) != expected:
+ arguments_s = 'argument' if expected == 1 else 'arguments'
+ raise SystemExit(
+ f'hook-impl for {hook_type} expected {expected} {arguments_s} '
+ f'but got {len(args)}: {args}',
+ )
+ else:
+ raise AssertionError(f'unexpected hook type: {hook_type}')
+
+
def _run_ns(
hook_type: str,
color: bool,
args: Sequence[str],
stdin: bytes,
) -> Optional[argparse.Namespace]:
+ _check_args_length(hook_type, args)
if hook_type == 'pre-push':
return _pre_push_ns(color, args, stdin)
- elif hook_type in {'prepare-commit-msg', 'commit-msg'}:
+ elif hook_type in {'commit-msg', 'prepare-commit-msg'}:
return _ns(hook_type, color, commit_msg_filename=args[0])
elif hook_type in {'pre-merge-commit', 'pre-commit'}:
return _ns(hook_type, color)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/pre_commit/commands/run.py
new/pre-commit-2.3.0/pre_commit/commands/run.py
--- old/pre-commit-2.2.0/pre_commit/commands/run.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/pre_commit/commands/run.py 2020-04-22
23:16:23.000000000 +0200
@@ -6,6 +6,7 @@
import re
import subprocess
import time
+import unicodedata
from typing import Any
from typing import Collection
from typing import Dict
@@ -33,8 +34,13 @@
logger = logging.getLogger('pre_commit')
+def _len_cjk(msg: str) -> int:
+ widths = {'A': 1, 'F': 2, 'H': 1, 'N': 1, 'Na': 1, 'W': 2}
+ return sum(widths[unicodedata.east_asian_width(c)] for c in msg)
+
+
def _start_msg(*, start: str, cols: int, end_len: int) -> str:
- dots = '.' * (cols - len(start) - end_len - 1)
+ dots = '.' * (cols - _len_cjk(start) - end_len - 1)
return f'{start}{dots}'
@@ -47,7 +53,7 @@
use_color: bool,
postfix: str = '',
) -> str:
- dots = '.' * (cols - len(start) - len(postfix) - len(end_msg) - 1)
+ dots = '.' * (cols - _len_cjk(start) - len(postfix) - len(end_msg) - 1)
end = color.format_color(end_msg, end_color, use_color)
return f'{start}{dots}{postfix}{end}\n'
@@ -206,7 +212,7 @@
Hook name...(no files to check) Skipped
"""
if hooks:
- name_len = max(len(hook.name) for hook in hooks)
+ name_len = max(_len_cjk(hook.name) for hook in hooks)
else:
name_len = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/pre_commit/languages/docker.py
new/pre-commit-2.3.0/pre_commit/languages/docker.py
--- old/pre-commit-2.2.0/pre_commit/languages/docker.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/pre_commit/languages/docker.py 2020-04-22
23:16:23.000000000 +0200
@@ -76,18 +76,18 @@
os.mkdir(directory)
-def get_docker_user() -> str: # pragma: win32 no cover
+def get_docker_user() -> Tuple[str, ...]: # pragma: win32 no cover
try:
- return f'{os.getuid()}:{os.getgid()}'
+ return ('-u', f'{os.getuid()}:{os.getgid()}')
except AttributeError:
- return '1000:1000'
+ return ()
def docker_cmd() -> Tuple[str, ...]: # pragma: win32 no cover
return (
'docker', 'run',
'--rm',
- '-u', get_docker_user(),
+ *get_docker_user(),
#
https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-from-container-volumes-from
# The `Z` option tells Docker to label the content with a private
# unshared label. Only the current container can use a private volume.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/pre_commit/languages/node.py
new/pre-commit-2.3.0/pre_commit/languages/node.py
--- old/pre-commit-2.2.0/pre_commit/languages/node.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/pre_commit/languages/node.py 2020-04-22
23:16:23.000000000 +0200
@@ -1,4 +1,5 @@
import contextlib
+import functools
import os
import sys
from typing import Generator
@@ -6,6 +7,7 @@
from typing import Tuple
import pre_commit.constants as C
+from pre_commit import parse_shebang
from pre_commit.envcontext import envcontext
from pre_commit.envcontext import PatchesT
from pre_commit.envcontext import Var
@@ -18,10 +20,22 @@
from pre_commit.util import cmd_output_b
ENVIRONMENT_DIR = 'node_env'
-get_default_version = helpers.basic_get_default_version
healthy = helpers.basic_healthy
[email protected]_cache(maxsize=1)
+def get_default_version() -> str:
+ # nodeenv does not yet support `-n system` on windows
+ if sys.platform == 'win32':
+ return C.DEFAULT
+ # if node is already installed, we can save a bunch of setup time by
+ # using the installed version
+ elif all(parse_shebang.find_executable(exe) for exe in ('node', 'npm')):
+ return 'system'
+ else:
+ return C.DEFAULT
+
+
def _envdir(prefix: Prefix, version: str) -> str:
directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
return prefix.path(directory)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/pre_commit/languages/python.py
new/pre-commit-2.3.0/pre_commit/languages/python.py
--- old/pre-commit-2.2.0/pre_commit/languages/python.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/pre_commit/languages/python.py 2020-04-22
23:16:23.000000000 +0200
@@ -182,8 +182,8 @@
version: str,
additional_dependencies: Sequence[str],
) -> None:
- additional_dependencies = tuple(additional_dependencies)
directory = helpers.environment_dir(_dir, version)
+ install = ('python', '-mpip', 'install', '.', *additional_dependencies)
env_dir = prefix.path(directory)
with clean_path_on_failure(env_dir):
@@ -193,9 +193,7 @@
python = os.path.realpath(sys.executable)
_make_venv(env_dir, python)
with in_env(prefix, version):
- helpers.run_setup_cmd(
- prefix, ('pip', 'install', '.') + additional_dependencies,
- )
+ helpers.run_setup_cmd(prefix, install)
return in_env, healthy, run_hook, install_environment
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/setup.cfg
new/pre-commit-2.3.0/setup.cfg
--- old/pre-commit-2.2.0/setup.cfg 2020-03-12 20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/setup.cfg 2020-04-22 23:16:23.000000000 +0200
@@ -1,6 +1,6 @@
[metadata]
name = pre_commit
-version = 2.2.0
+version = 2.3.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.2.0/tests/color_test.py
new/pre-commit-2.3.0/tests/color_test.py
--- old/pre-commit-2.2.0/tests/color_test.py 2020-03-12 20:37:15.000000000
+0100
+++ new/pre-commit-2.3.0/tests/color_test.py 2020-04-22 23:16:23.000000000
+0200
@@ -29,26 +29,26 @@
def test_use_color_no_tty():
- with mock.patch.object(sys.stdout, 'isatty', return_value=False):
+ with mock.patch.object(sys.stderr, 'isatty', return_value=False):
assert use_color('auto') is False
def test_use_color_tty_with_color_support():
- with mock.patch.object(sys.stdout, 'isatty', return_value=True):
+ with mock.patch.object(sys.stderr, 'isatty', return_value=True):
with mock.patch('pre_commit.color.terminal_supports_color', True):
with envcontext.envcontext((('TERM', envcontext.UNSET),)):
assert use_color('auto') is True
def test_use_color_tty_without_color_support():
- with mock.patch.object(sys.stdout, 'isatty', return_value=True):
+ with mock.patch.object(sys.stderr, 'isatty', return_value=True):
with mock.patch('pre_commit.color.terminal_supports_color', False):
with envcontext.envcontext((('TERM', envcontext.UNSET),)):
assert use_color('auto') is False
def test_use_color_dumb_term():
- with mock.patch.object(sys.stdout, 'isatty', return_value=True):
+ with mock.patch.object(sys.stderr, 'isatty', return_value=True):
with mock.patch('pre_commit.color.terminal_supports_color', True):
with envcontext.envcontext((('TERM', 'dumb'),)):
assert use_color('auto') is False
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/tests/commands/autoupdate_test.py
new/pre-commit-2.3.0/tests/commands/autoupdate_test.py
--- old/pre-commit-2.2.0/tests/commands/autoupdate_test.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/tests/commands/autoupdate_test.py 2020-04-22
23:16:23.000000000 +0200
@@ -263,6 +263,45 @@
assert cfg.read() == expected
+def test_does_not_change_mixed_endlines_read(up_to_date, tmpdir, store):
+ fmt = (
+ 'repos:\n'
+ '- repo: {}\n'
+ ' rev: {} # definitely the version I want!\r\n'
+ ' hooks:\r\n'
+ ' - id: foo\n'
+ ' # These args are because reasons!\r\n'
+ ' args: [foo, bar, baz]\r\n'
+ )
+ cfg = tmpdir.join(C.CONFIG_FILE)
+
+ expected = fmt.format(up_to_date, git.head_rev(up_to_date)).encode()
+ cfg.write_binary(expected)
+
+ assert autoupdate(str(cfg), store, freeze=False, tags_only=False) == 0
+ assert cfg.read_binary() == expected
+
+
+def test_does_not_change_mixed_endlines_write(tmpdir, out_of_date, store):
+ fmt = (
+ 'repos:\n'
+ '- repo: {}\n'
+ ' rev: {} # definitely the version I want!\r\n'
+ ' hooks:\r\n'
+ ' - id: foo\n'
+ ' # These args are because reasons!\r\n'
+ ' args: [foo, bar, baz]\r\n'
+ )
+ cfg = tmpdir.join(C.CONFIG_FILE)
+ cfg.write_binary(
+ fmt.format(out_of_date.path, out_of_date.original_rev).encode(),
+ )
+
+ assert autoupdate(str(cfg), store, freeze=False, tags_only=False) == 0
+ expected = fmt.format(out_of_date.path, out_of_date.head_rev).encode()
+ assert cfg.read_binary() == expected
+
+
def test_loses_formatting_when_not_detectable(out_of_date, store, tmpdir):
"""A best-effort attempt is made at updating rev without rewriting
formatting. When the original formatting cannot be detected, this
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/tests/commands/hook_impl_test.py
new/pre-commit-2.3.0/tests/commands/hook_impl_test.py
--- old/pre-commit-2.2.0/tests/commands/hook_impl_test.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/tests/commands/hook_impl_test.py 2020-04-22
23:16:23.000000000 +0200
@@ -89,6 +89,51 @@
call()
[email protected](
+ ('hook_type', 'args'),
+ (
+ ('pre-commit', []),
+ ('pre-merge-commit', []),
+ ('pre-push', ['branch_name', 'remote_name']),
+ ('commit-msg', ['.git/COMMIT_EDITMSG']),
+ ('post-checkout', ['old_head', 'new_head', '1']),
+ # multiple choices for commit-editmsg
+ ('prepare-commit-msg', ['.git/COMMIT_EDITMSG']),
+ ('prepare-commit-msg', ['.git/COMMIT_EDITMSG', 'message']),
+ ('prepare-commit-msg', ['.git/COMMIT_EDITMSG', 'commit', 'deadbeef']),
+ ),
+)
+def test_check_args_length_ok(hook_type, args):
+ hook_impl._check_args_length(hook_type, args)
+
+
+def test_check_args_length_error_too_many_plural():
+ with pytest.raises(SystemExit) as excinfo:
+ hook_impl._check_args_length('pre-commit', ['run', '--all-files'])
+ msg, = excinfo.value.args
+ assert msg == (
+ 'hook-impl for pre-commit expected 0 arguments but got 2: '
+ "['run', '--all-files']"
+ )
+
+
+def test_check_args_length_error_too_many_singluar():
+ with pytest.raises(SystemExit) as excinfo:
+ hook_impl._check_args_length('commit-msg', [])
+ msg, = excinfo.value.args
+ assert msg == 'hook-impl for commit-msg expected 1 argument but got 0: []'
+
+
+def test_check_args_length_prepare_commit_msg_error():
+ with pytest.raises(SystemExit) as excinfo:
+ hook_impl._check_args_length('prepare-commit-msg', [])
+ msg, = excinfo.value.args
+ assert msg == (
+ 'hook-impl for prepare-commit-msg expected 1, 2, or 3 arguments '
+ 'but got 0: []'
+ )
+
+
def test_run_ns_pre_commit():
ns = hook_impl._run_ns('pre-commit', True, (), b'')
assert ns is not None
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/tests/commands/run_test.py
new/pre-commit-2.3.0/tests/commands/run_test.py
--- old/pre-commit-2.2.0/tests/commands/run_test.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/tests/commands/run_test.py 2020-04-22
23:16:23.000000000 +0200
@@ -52,6 +52,18 @@
assert ret == 'start......end\n'
+def test_full_msg_with_cjk():
+ ret = _full_msg(
+ start='啊あ아',
+ end_msg='end',
+ end_color='',
+ use_color=False,
+ cols=15,
+ )
+ # 5 dots: 15 - 6 - 3 - 1
+ assert ret == '啊あ아.....end\n'
+
+
def test_full_msg_with_color():
ret = _full_msg(
start='start',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/tests/languages/docker_test.py
new/pre-commit-2.3.0/tests/languages/docker_test.py
--- old/pre-commit-2.2.0/tests/languages/docker_test.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/tests/languages/docker_test.py 2020-04-22
23:16:23.000000000 +0200
@@ -20,4 +20,4 @@
getuid=invalid_attribute,
getgid=invalid_attribute,
):
- assert docker.get_docker_user() == '1000:1000'
+ assert docker.get_docker_user() == ()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/tests/languages/node_test.py
new/pre-commit-2.3.0/tests/languages/node_test.py
--- old/pre-commit-2.2.0/tests/languages/node_test.py 1970-01-01
01:00:00.000000000 +0100
+++ new/pre-commit-2.3.0/tests/languages/node_test.py 2020-04-22
23:16:23.000000000 +0200
@@ -0,0 +1,47 @@
+import sys
+from unittest import mock
+
+import pytest
+
+import pre_commit.constants as C
+from pre_commit import parse_shebang
+from pre_commit.languages.node import get_default_version
+
+
+ACTUAL_GET_DEFAULT_VERSION = get_default_version.__wrapped__
+
+
[email protected]
+def is_linux():
+ with mock.patch.object(sys, 'platform', 'linux'):
+ yield
+
+
[email protected]
+def is_win32():
+ with mock.patch.object(sys, 'platform', 'win32'):
+ yield
+
+
[email protected]
+def find_exe_mck():
+ with mock.patch.object(parse_shebang, 'find_executable') as mck:
+ yield mck
+
+
[email protected]('is_linux')
+def test_sets_system_when_node_and_npm_are_available(find_exe_mck):
+ find_exe_mck.return_value = '/path/to/exe'
+ assert ACTUAL_GET_DEFAULT_VERSION() == 'system'
+
+
[email protected]('is_linux')
+def test_uses_default_when_node_and_npm_are_not_available(find_exe_mck):
+ find_exe_mck.return_value = None
+ assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT
+
+
[email protected]('is_win32')
+def test_sets_default_on_windows(find_exe_mck):
+ find_exe_mck.return_value = '/path/to/exe'
+ assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pre-commit-2.2.0/tests/repository_test.py
new/pre-commit-2.3.0/tests/repository_test.py
--- old/pre-commit-2.2.0/tests/repository_test.py 2020-03-12
20:37:15.000000000 +0100
+++ new/pre-commit-2.3.0/tests/repository_test.py 2020-04-22
23:16:23.000000000 +0200
@@ -131,9 +131,9 @@
def test_python_hook_default_version(tempdir_factory, store):
# make sure that this continues to work for platforms where default
# language detection does not work
- with mock.patch.object(
- python, 'get_default_version', return_value=C.DEFAULT,
- ):
+ returns_default = mock.Mock(return_value=C.DEFAULT)
+ lang = languages['python']._replace(get_default_version=returns_default)
+ with mock.patch.dict(languages, python=lang):
test_python_hook(tempdir_factory, store)
@@ -243,6 +243,15 @@
)
+def test_run_a_node_hook_default_version(tempdir_factory, store):
+ # make sure that this continues to work for platforms where node is not
+ # installed at the system
+ returns_default = mock.Mock(return_value=C.DEFAULT)
+ lang = languages['node']._replace(get_default_version=returns_default)
+ with mock.patch.dict(languages, node=lang):
+ test_run_a_node_hook(tempdir_factory, store)
+
+
def test_run_versioned_node_hook(tempdir_factory, store):
_test_hook_repo(
tempdir_factory, store, 'node_versioned_hooks_repo',