diff --git a/.gitignore b/.gitignore index 1d71e65c..c51be233 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 230fe8d2..ee2b156b 100644 --- a/start.py +++ b/start.py @@ -14,6 +14,24 @@ 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", + "--short", + "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.