Display the site's commit hash

This commit is contained in:
sharkykh 2017-05-14 12:02:39 +03:00
parent a7d3c5a4de
commit 2a71fd8158
2 changed files with 10 additions and 0 deletions

View File

@ -40,6 +40,13 @@ if not app.config['DEBUG']:
'<strong>An error occured!</strong> 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

View File

@ -221,6 +221,9 @@
<footer style="text-align: center;">
<p>Dark Mode: <a href="#" id="themeToggle">Toggle</a></p>
{% if config.COMMIT_HASH %}
<p>Commit: <a href="https://github.com/nyaadevs/nyaa/tree/{{ config.COMMIT_HASH }}">{{ config.COMMIT_HASH[:7] }}</a></p>
{% endif %}
</footer>
</body>
</html>