From 1985e1f40d5cdc790ed556777ca5e4f572550b72 Mon Sep 17 00:00:00 2001 From: Sebastian Gode Date: Fri, 6 Sep 2024 07:28:44 +0000 Subject: [PATCH 1/2] Added Commit Hash and Time to confpy --- otc_metadata/templates/conf.py.j2 | 7 +++++++ otc_metadata/templates/doc_requirements.txt.j2 | 1 + 2 files changed, 8 insertions(+) diff --git a/otc_metadata/templates/conf.py.j2 b/otc_metadata/templates/conf.py.j2 index 16f1f91..163c6b5 100644 --- a/otc_metadata/templates/conf.py.j2 +++ b/otc_metadata/templates/conf.py.j2 @@ -16,6 +16,8 @@ import os import sys +from git import Repo +from datetime import datetime extensions = [ 'otcdocstheme', @@ -132,3 +134,8 @@ latex_documents = [ {% endif -%} ] +# Get the Git commit values +repo = Repo(search_parent_directories=True) +commit = repo.head.commit +current_commit_hash = commit.hexsha[:7] +current_commit_time = commit.committed_datetime.strftime('%Y-%m-%d %H:%M') diff --git a/otc_metadata/templates/doc_requirements.txt.j2 b/otc_metadata/templates/doc_requirements.txt.j2 index 1c5d41a..ee81551 100644 --- a/otc_metadata/templates/doc_requirements.txt.j2 +++ b/otc_metadata/templates/doc_requirements.txt.j2 @@ -13,3 +13,4 @@ otc-sphinx-directives>=0.1.0 sphinx-minify>=0.0.1 # Apache-2.0 git+https://gitea.eco.tsi-dev.otc-service.com/infra/otc-metadata-swiss.git#egg=otc_metadata setuptools +gitpython -- 2.34.1 From 6068d7cea1a79a0cdad0b19e2e6b8fc16c2637bd Mon Sep 17 00:00:00 2001 From: Sebastian Gode Date: Fri, 6 Sep 2024 07:52:49 +0000 Subject: [PATCH 2/2] Added Commit Hash and Time to confpy --- otc_metadata/templates/conf.py.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/otc_metadata/templates/conf.py.j2 b/otc_metadata/templates/conf.py.j2 index 163c6b5..54ad7d9 100644 --- a/otc_metadata/templates/conf.py.j2 +++ b/otc_metadata/templates/conf.py.j2 @@ -134,8 +134,8 @@ latex_documents = [ {% endif -%} ] -# Get the Git commit values +# Get the Git commit values for timestamp on each page repo = Repo(search_parent_directories=True) commit = repo.head.commit -current_commit_hash = commit.hexsha[:7] +current_commit_hash = commit.hexsha current_commit_time = commit.committed_datetime.strftime('%Y-%m-%d %H:%M') -- 2.34.1