From 7ec077260212e7724201cad00dafd77e7a9d10b9 Mon Sep 17 00:00:00 2001 From: "Gode, Sebastian" Date: Fri, 6 Sep 2024 07:35:42 +0000 Subject: [PATCH] Added Commit Hash and Time to confpy Reviewed-by: tischrei Co-authored-by: Gode, Sebastian Co-committed-by: Gode, Sebastian --- otc_metadata/templates/conf.py.j2 | 7 +++++++ otc_metadata/templates/doc_requirements.txt.j2 | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/otc_metadata/templates/conf.py.j2 b/otc_metadata/templates/conf.py.j2 index 7db2f711..df824e60 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', @@ -131,3 +133,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 3f070fc4..61cdd1bf 100644 --- a/otc_metadata/templates/doc_requirements.txt.j2 +++ b/otc_metadata/templates/doc_requirements.txt.j2 @@ -12,4 +12,5 @@ reno>=3.1.0 # Apache-2.0 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.git#egg=otc_metadata -setuptools \ No newline at end of file +setuptools +gitpython