feat: Move getGitCommit from api to tools
All checks were successful
Build Docker / BuildImage (push) Successful in 1m4s

This commit is contained in:
2025-10-11 18:51:22 +11:00
parent 258061c64d
commit bfc1f0839a
3 changed files with 24 additions and 23 deletions

View File

@@ -4,7 +4,7 @@ import datetime
import requests
from mail import sendEmail
from sol import create_transaction
from tools import getClientIP
from tools import getClientIP, getGitCommit
api_bp = Blueprint('api', __name__)
@@ -18,26 +18,6 @@ if 'time-zone' not in ncConfig:
ncConfig['time-zone'] = 10
def getGitCommit():
# if .git exists, get the latest commit hash
if os.path.isdir(".git"):
git_dir = ".git"
head_ref = ""
with open(os.path.join(git_dir, "HEAD")) as file:
head_ref = file.read().strip()
if head_ref.startswith("ref: "):
head_ref = head_ref[5:]
with open(os.path.join(git_dir, head_ref)) as file:
return file.read().strip()
else:
return head_ref
# Check if env SOURCE_COMMIT is set
if "SOURCE_COMMIT" in os.environ:
return os.environ["SOURCE_COMMIT"]
return "failed to get version"
@api_bp.route("/")
@api_bp.route("/help")
def help_get():