Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: log the current commit hash #233

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,6 @@ openapi.json

# Backup files
*.bak

# Commit hash
endpoints/OAI/_commit.py
18 changes: 18 additions & 0 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading