From d46c288cfdeadb070fa71c744b9970b3f1c7a623 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 12 Aug 2021 14:03:27 +0200 Subject: Merging upstream version 2.14.0. Signed-off-by: Daniel Baumann --- tests/commands/install_uninstall_test.py | 17 +++++++++++++++-- tests/commands/run_test.py | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'tests/commands') 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) -- cgit v1.2.3