From 14f7f5c6ac1d507405753dc7a0a34430d1aac26d Mon Sep 17 00:00:00 2001 From: Clemens Barth Date: Wed, 26 Apr 2023 15:52:09 +0200 Subject: [PATCH] Git hash is now also in. --- AFM_thumbs/Variables.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/AFM_thumbs/Variables.py b/AFM_thumbs/Variables.py index a958fd6..95a54e9 100755 --- a/AFM_thumbs/Variables.py +++ b/AFM_thumbs/Variables.py @@ -24,6 +24,9 @@ # DO NOT REMOVE THIS PREAMBLE !!! # +import time +import pathlib + # # @@ -47,20 +50,25 @@ globvar_configfile_path = "./AFM_thumbs/" # # # _____________________________________________________________________ to here -# -# -# +# ____________________________________________________________ Git hash version +# Get the git hash version +def get_git_revision(base_path): + + git_dir = pathlib.Path(base_path) / '.git' + + with (git_dir / 'HEAD').open('r') as head: + ref = head.readline().split(' ')[-1].strip() + with (git_dir / ref).open('r') as git_hash: + return git_hash.readline().strip() # ____________________________________________________________ Global variables # DO NOT CHANGE ANYTHING BELOW, OTHERWISE YOU KNOW WHAT TO DO ! -import time - globvar_contributions = "Reinhard Olbrich (testing)\n" \ "Matthias Temmen (testing)\n" \ "Alexander v Schmidtsfeld (testing)\n" \ @@ -68,6 +76,7 @@ globvar_contributions = "Reinhard Olbrich (testing)\n" \ globvar_year = "2023-04-26" globvar_version = "3.0.1111" +globvar_git_version = get_git_revision(os.path.join(os.path.dirname(__file__), "../")) globvar_spaces = " " globvar_name = "AFM thumbs v" + globvar_version @@ -85,14 +94,15 @@ globvar_note = ("Version " + globvar_version + " (" + "Contributions from:\n" + globvar_contributions) -globvar_console = ("\n\n"+ - globvar_spaces + - globvar_name + " - " + - globvar_year + "\n" + - globvar_spaces + "www.root-1.de\n\n" + - globvar_spaces + "Today: " + - time.strftime("%d-%m-%Y") + - ", Time: " + +globvar_console = ("\n\n" + + globvar_spaces + + globvar_name + " - " + + globvar_year + "\n" + + "GIT commit: " + globvar_git_version + "\n" + + globvar_spaces + "www.root-1.de\n\n" + + globvar_spaces + "Today: " + + time.strftime("%d-%m-%Y") + + ", Time: " + time.strftime("%H:%M:%S")) globvar_python_directory = "AFM_thumbs"