Skip to content

Commit

Permalink
fix: unable to find default template for CHANGELOG generation
Browse files Browse the repository at this point in the history
  • Loading branch information
panpuchkov committed Dec 28, 2023
1 parent b9a0deb commit 70933b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ pygitver = "pygitver.pygitver:main"

[metadata]
url = "https://github.com/panpuchkov/pygitver"


[tool.setuptools.package-data]
pygitver = ["*.py", "*.tmpl"]
4 changes: 3 additions & 1 deletion src/pygitver/changelogs_mngr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pathlib
import json
from pygitver.git import Git, GitError

Expand Down Expand Up @@ -51,9 +52,10 @@ def read_files(self, path: str, file_ext: str = "json"):

def generate(self, template_name: str = "") -> str:
if not template_name:
script_directory = pathlib.Path(__file__).parent.resolve()
template_name = os.getenv(
"PYGITVER_TEMPLATE_CHANGELOG_COMMON",
"pygitver/templates/changelog-common.tmpl",
f"{script_directory}/templates/changelog-common.tmpl",
)
try:
env = Environment(loader=FileSystemLoader(os.path.dirname(template_name)))
Expand Down
7 changes: 5 additions & 2 deletions src/pygitver/git.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import pathlib
import json
import re
import subprocess
from jinja2 import Environment, FileSystemLoader, TemplateNotFound
Expand Down Expand Up @@ -252,8 +253,10 @@ def changelog_generate(changelog_group: dict, template_name: str = "") -> str:
:return: string with formatted changelog
"""
if not template_name:
script_directory = pathlib.Path(__file__).parent.resolve()
template_name = os.getenv(
"PYGITVER_TEMPLATE_CHANGELOG", "templates/changelog.tmpl"
"PYGITVER_TEMPLATE_CHANGELOG",
f"{script_directory}/templates/changelog.tmpl",
)
try:
env = Environment(loader=FileSystemLoader(os.path.dirname(template_name)))
Expand Down

0 comments on commit 70933b6

Please sign in to comment.