From e34a6adf16d420be8400e8cceda4e18634e0ad55 Mon Sep 17 00:00:00 2001 From: AlpinDale Date: Mon, 4 Nov 2024 13:54:48 +0000 Subject: [PATCH 1/2] feat: log the current commit hash --- .gitignore | 3 +++ start.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index 1d71e65..c51be23 100644 --- a/.gitignore +++ b/.gitignore @@ -216,3 +216,6 @@ openapi.json # Backup files *.bak + +# Commit hash +endpoints/OAI/_commit.py diff --git a/start.py b/start.py index 230fe8d..cab7999 100644 --- a/start.py +++ b/start.py @@ -14,6 +14,23 @@ start_options = {} +def print_commit_hash(): + """Prints the commit hash of the current branch or a + placeholder if git is not available (probably windows users)""" + try: + commit_hash = subprocess.check_output(["git", + "rev-parse", + "HEAD"]).decode("utf-8").strip() + except (subprocess.CalledProcessError, FileNotFoundError): + commit_hash = "placeholder" + + with open("endpoints/OAI/_commit.py", "w") as commit_file: + contents = f"""commit_hash = "{commit_hash}" """ + commit_file.write(contents) + +print_commit_hash() + + def get_user_choice(question: str, options_dict: dict): """ Gets user input in a commandline script. From efed8c617eed0c998b408c318da1d06e6ec70a81 Mon Sep 17 00:00:00 2001 From: AlpinDale Date: Mon, 4 Nov 2024 13:58:14 +0000 Subject: [PATCH 2/2] log the short head --- start.py | 1 + 1 file changed, 1 insertion(+) diff --git a/start.py b/start.py index cab7999..ee2b156 100644 --- a/start.py +++ b/start.py @@ -20,6 +20,7 @@ def print_commit_hash(): try: commit_hash = subprocess.check_output(["git", "rev-parse", + "--short", "HEAD"]).decode("utf-8").strip() except (subprocess.CalledProcessError, FileNotFoundError): commit_hash = "placeholder"