From 1e5cd2187b4686465d8066e6df00930e2df8e5d4 Mon Sep 17 00:00:00 2001 From: Russ Ferriday Date: Mon, 15 Nov 2021 14:53:49 +0000 Subject: [PATCH 1/3] Add messages for repo error --- git_version/templatetags/git_tags.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/git_version/templatetags/git_tags.py b/git_version/templatetags/git_tags.py index 3ef9104..ddb5ba3 100644 --- a/git_version/templatetags/git_tags.py +++ b/git_version/templatetags/git_tags.py @@ -5,11 +5,15 @@ @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: + print(f"git_version - trouble with repo path {path}") + return "no git?" @register.simple_tag def current_commit_short(path): From f18e59af61cf0c71b30173ec89adb276a9dcf959 Mon Sep 17 00:00:00 2001 From: Russ Ferriday Date: Tue, 8 Mar 2022 17:22:49 +0000 Subject: [PATCH 2/3] Updated per PR comments from owner --- git_version/templatetags/git_tags.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/git_version/templatetags/git_tags.py b/git_version/templatetags/git_tags.py index ddb5ba3..bc26012 100644 --- a/git_version/templatetags/git_tags.py +++ b/git_version/templatetags/git_tags.py @@ -1,8 +1,12 @@ +import logging from django import template from git import Repo +logger = logging.getLogger(__name__) + register = template.Library() + @register.simple_tag def current_commit(path): try: @@ -11,10 +15,12 @@ def current_commit(path): chash = commit.hexsha repo.__del__() return chash - except Exception: - print(f"git_version - trouble with repo path {path}") + 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): return current_commit(path)[:8] From e994d724cc61d85e9e56dad3e9910e5f6683ee23 Mon Sep 17 00:00:00 2001 From: Russ Ferriday Date: Tue, 8 Mar 2022 17:33:45 +0000 Subject: [PATCH 3/3] Attempt upgrade to 4.x.x --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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=[