fix: made commit hash consistent with the running server

This commit is contained in:
ffqq 2023-07-13 03:05:33 +00:00
parent df75e02efc
commit 69d6020865
2 changed files with 5 additions and 16 deletions

19
main
View File

@ -127,17 +127,8 @@ def get_session(id):
return "error"
return post
def get_current_commit(output_format="full"):
if output_format == "short":
length = 8
else:
length = 40
try:
output = subprocess.check_output(["git", "rev-parse", f"--short={length}", "HEAD"]).decode().strip()
return output
except subprocess.CalledProcessError:
return "Error fetching git commit"
full_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
short_hash = subprocess.check_output(["git", "rev-parse", "--short=8", "HEAD"]).decode().strip()
ALLOWED_EXTENSIONS = {"png", "apng", "jpg", "jpeg", "gif", "svg", "webp"}
@ -151,16 +142,14 @@ def main():
usersession = request.cookies.get("session_DO_NOT_SHARE")
conn = get_db_connection()
posts = conn.execute("SELECT * FROM posts ORDER BY created DESC;").fetchall()
commit_hash_long = get_current_commit()
commit_hash_short = get_current_commit(output_format="short")
conn.close()
if usersession:
userCookie = get_session(usersession)
user = get_user(userCookie["id"])
return render_template("main.html", userdata=user, posts=posts, commit_hash_long=commit_hash_long, commit_hash_short=commit_hash_short)
return render_template("main.html", userdata=user, posts=posts, full_hash=full_hash, short_hash=short_hash)
else:
return render_template("main.html", posts=posts, commit_hash_long=commit_hash_long, commit_hash_short=commit_hash_short)
return render_template("main.html", posts=posts, full_hash=full_hash, short_hash=short_hash)
@app.route("/chat", methods=("GET", "POST"))
def chat():

View File

@ -116,7 +116,7 @@
<div class="bottom">
<span>
<a href="https://codeberg.org/burger-software/burgercat">burgercat</a>
<a href="https://codeberg.org/burger-software/burgercat/commit/{{ commit_hash_long }}" style="float: right;">commit hash: {{ commit_hash_short }}</a>
<a href="https://codeberg.org/burger-software/burgercat/commit/{{ full_hash }}" style="float: right;">commit hash: {{ short_hash }}</a>
</span>
</div>
<script src="/static/js/main.js"></script>