summaryrefslogtreecommitdiffstats
path: root/tests/commands
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-08-12 12:03:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-08-12 12:03:24 +0000
commitdb201c7e8329ebc584fbebcc18f5b64825f6d023 (patch)
treeeed388903a58a2988bdf587ee7c7622d167226f7 /tests/commands
parentAdding upstream version 2.13.0. (diff)
downloadpre-commit-db201c7e8329ebc584fbebcc18f5b64825f6d023.tar.xz
pre-commit-db201c7e8329ebc584fbebcc18f5b64825f6d023.zip
Adding upstream version 2.14.0.upstream/2.14.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/commands')
-rw-r--r--tests/commands/install_uninstall_test.py17
-rw-r--r--tests/commands/run_test.py1
2 files changed, 16 insertions, 2 deletions
diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py
index bd28654..314b8b9 100644
--- a/tests/commands/install_uninstall_test.py
+++ b/tests/commands/install_uninstall_test.py
@@ -39,7 +39,7 @@ def test_is_script():
def test_is_previous_pre_commit(tmpdir):
f = tmpdir.join('foo')
- f.write(f'{PRIOR_HASHES[0]}\n')
+ f.write(f'{PRIOR_HASHES[0].decode()}\n')
assert is_our_script(f.strpath)
@@ -390,6 +390,19 @@ def test_install_existing_hook_no_overwrite_idempotent(tempdir_factory, store):
NORMAL_PRE_COMMIT_RUN.assert_matches(output[len('legacy hook\n'):])
+def test_install_with_existing_non_utf8_script(tmpdir, store):
+ cmd_output('git', 'init', str(tmpdir))
+ tmpdir.join('.git/hooks').ensure_dir()
+ tmpdir.join('.git/hooks/pre-commit').write_binary(
+ b'#!/usr/bin/env bash\n'
+ b'# garbage: \xa0\xef\x12\xf2\n'
+ b'echo legacy hook\n',
+ )
+
+ with tmpdir.as_cwd():
+ assert install(C.CONFIG_FILE, store, hook_types=['pre-commit']) == 0
+
+
FAIL_OLD_HOOK = re_assert.Matches(
r'fail!\n'
r'\[INFO\] Initializing environment for .+\.\n'
@@ -460,7 +473,7 @@ def test_replace_old_commit_script(tempdir_factory, store):
# Install a script that looks like our old script
pre_commit_contents = resource_text('hook-tmpl')
new_contents = pre_commit_contents.replace(
- CURRENT_HASH, PRIOR_HASHES[-1],
+ CURRENT_HASH.decode(), PRIOR_HASHES[-1].decode(),
)
os.makedirs(os.path.join(path, '.git/hooks'), exist_ok=True)
diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py
index e184340..da7569e 100644
--- a/tests/commands/run_test.py
+++ b/tests/commands/run_test.py
@@ -487,6 +487,7 @@ def test_all_push_options_ok(cap_out, store, repo_with_passing_hook):
args = run_opts(
from_ref='master', to_ref='master',
remote_branch='master',
+ local_branch='master',
remote_name='origin', remote_url='https://example.com/repo',
)
ret, printed = _do_run(cap_out, store, repo_with_passing_hook, args)