diff --git a/pre_commit_hooks/prepare_commit_msg.py b/pre_commit_hooks/prepare_commit_msg.py index c8ff3e8..ef91ad2 100644 --- a/pre_commit_hooks/prepare_commit_msg.py +++ b/pre_commit_hooks/prepare_commit_msg.py @@ -8,7 +8,7 @@ from jinja2 import Template from pre_commit_hooks.util import CalledProcessError from pre_commit_hooks.util import cmd_output -from testing.util import get_template_path +from pre_commit_hooks.util import get_template_path def get_current_branch() -> str: diff --git a/pre_commit_hooks/util.py b/pre_commit_hooks/util.py index d6c90ae..64c026f 100644 --- a/pre_commit_hooks/util.py +++ b/pre_commit_hooks/util.py @@ -1,5 +1,6 @@ from __future__ import annotations +import os import subprocess from typing import Any @@ -30,3 +31,8 @@ def zsplit(s: str) -> list[str]: return s.split('\0') else: return [] + + +def get_template_path(path: str) -> str: + parent_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) + return os.path.join(parent_dir, 'templates', path) diff --git a/testing/util.py b/testing/util.py index fb735b3..2bbbe64 100644 --- a/testing/util.py +++ b/testing/util.py @@ -14,8 +14,3 @@ def get_resource_path(path): def git_commit(*args, **kwargs): cmd = ('git', 'commit', '--no-gpg-sign', '--no-verify', '--no-edit', *args) subprocess.check_call(cmd, **kwargs) - - -def get_template_path(path): - parent_dir = os.path.abspath(os.path.join(TESTING_DIR, os.pardir)) - return os.path.join(parent_dir, 'templates', path) diff --git a/tests/prepare_commit_msg_test.py b/tests/prepare_commit_msg_test.py index e066cd6..d2a4c7e 100644 --- a/tests/prepare_commit_msg_test.py +++ b/tests/prepare_commit_msg_test.py @@ -6,7 +6,7 @@ from pre_commit_hooks.prepare_commit_msg import get_current_branch from pre_commit_hooks.prepare_commit_msg import main from pre_commit_hooks.prepare_commit_msg import update_commit_file from pre_commit_hooks.util import cmd_output -from testing.util import get_template_path +from pre_commit_hooks.util import get_template_path def test_current_branch(temp_git_dir):