fix: made commit hash consistent with the running server
This commit is contained in:
parent
df75e02efc
commit
69d6020865
19
main
19
main
|
@ -127,17 +127,8 @@ def get_session(id):
|
||||||
return "error"
|
return "error"
|
||||||
return post
|
return post
|
||||||
|
|
||||||
def get_current_commit(output_format="full"):
|
full_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
|
||||||
if output_format == "short":
|
short_hash = subprocess.check_output(["git", "rev-parse", "--short=8", "HEAD"]).decode().strip()
|
||||||
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"
|
|
||||||
|
|
||||||
ALLOWED_EXTENSIONS = {"png", "apng", "jpg", "jpeg", "gif", "svg", "webp"}
|
ALLOWED_EXTENSIONS = {"png", "apng", "jpg", "jpeg", "gif", "svg", "webp"}
|
||||||
|
|
||||||
|
@ -151,16 +142,14 @@ def main():
|
||||||
usersession = request.cookies.get("session_DO_NOT_SHARE")
|
usersession = request.cookies.get("session_DO_NOT_SHARE")
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
posts = conn.execute("SELECT * FROM posts ORDER BY created DESC;").fetchall()
|
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()
|
conn.close()
|
||||||
|
|
||||||
if usersession:
|
if usersession:
|
||||||
userCookie = get_session(usersession)
|
userCookie = get_session(usersession)
|
||||||
user = get_user(userCookie["id"])
|
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:
|
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"))
|
@app.route("/chat", methods=("GET", "POST"))
|
||||||
def chat():
|
def chat():
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
<div class="bottom">
|
<div class="bottom">
|
||||||
<span>
|
<span>
|
||||||
<a href="https://codeberg.org/burger-software/burgercat">burgercat</a>
|
<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>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<script src="/static/js/main.js"></script>
|
<script src="/static/js/main.js"></script>
|
||||||
|
|
Reference in New Issue