diff --git a/git_version/templatetags/git_tags.py b/git_version/templatetags/git_tags.py index 3ef9104..bc26012 100644 --- a/git_version/templatetags/git_tags.py +++ b/git_version/templatetags/git_tags.py @@ -1,15 +1,25 @@ +import logging from django import template from git import Repo +logger = logging.getLogger(__name__) + register = template.Library() + @register.simple_tag def current_commit(path): - repo = Repo(path) - commit = repo.commit() - chash = commit.hexsha - repo.__del__() - return chash + try: + repo = Repo(path) + commit = repo.commit() + chash = commit.hexsha + repo.__del__() + return chash + except Exception as e: + logger.debug(f"Failed to find current commit for {path}") + logger.debug(f"Exception was: {e}") + return "no git?" + @register.simple_tag def current_commit_short(path): diff --git a/setup.py b/setup.py index b93f2f1..3a2da5b 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ author='Daniel Seiler', author_email='daniel.seiler@fachschaft.informatik.tu-darmstadt.de', install_requires=[ - 'django<4', + 'django<5', 'gitpython', ], classifiers=[