Move get_template_path function to pakcage utils

Moved out the function from testing package to project main package.
This commit is contained in:
David Paz 2022-07-15 14:49:26 +02:00
parent 51e5b74f80
commit f072bb622f
No known key found for this signature in database
GPG key ID: 6600CC47B1C1B063
4 changed files with 8 additions and 7 deletions

View file

@ -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:

View file

@ -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)

View file

@ -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)

View file

@ -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):