From 2a71fd8158af1f878a85f0c0fa1a022d46be8f08 Mon Sep 17 00:00:00 2001 From: sharkykh Date: Sun, 14 May 2017 12:02:39 +0300 Subject: [PATCH] Display the site's commit hash --- nyaa/__init__.py | 7 +++++++ nyaa/templates/layout.html | 3 +++ 2 files changed, 10 insertions(+) diff --git a/nyaa/__init__.py b/nyaa/__init__.py index bea32da..aeda6be 100644 --- a/nyaa/__init__.py +++ b/nyaa/__init__.py @@ -40,6 +40,13 @@ if not app.config['DEBUG']: 'An error occured! Debugging information has been logged.'), 'danger') return flask.redirect('/') +# Get git commit hash +app.config['COMMIT_HASH'] = None +master_head = os.path.abspath(os.path.join(os.path.dirname(__file__), '../.git/refs/heads/master')) +if os.path.isfile(master_head): + with open(master_head, 'r') as head: + app.config['COMMIT_HASH'] = head.readline().strip() + # Enable the jinja2 do extension. app.jinja_env.add_extension('jinja2.ext.do') app.jinja_env.lstrip_blocks = True diff --git a/nyaa/templates/layout.html b/nyaa/templates/layout.html index 3f70770..be76608 100644 --- a/nyaa/templates/layout.html +++ b/nyaa/templates/layout.html @@ -221,6 +221,9 @@