Skip to content
Snippets Groups Projects
Commit 6c7794d1 authored by Nils G.'s avatar Nils G.
Browse files

Added meta table which parses git commit and date

parent 826048b0
No related branches found
No related tags found
No related merge requests found
import random
def index():
return dict(var=random.random())
return dict(var=random.random(), meta=db(db.Meta).select().first())
import subprocess
db.define_table(
'Meta',
Field('creation', 'datetime', default=request.now),
Field('git_commit', 'string'),
Field('git_date', 'string')
)
def getGitCommit(_record):
try:
commit = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=request.folder, encoding="utf-8")[:-1]
except:
commit = "Failed to get git commit"
return(commit)
def getGitDate(_record):
try:
date = subprocess.check_output(["git", "log", "-1", "--format=%cd", "--date=iso8601"], cwd=request.folder, encoding="utf-8")[:-7]
except:
date = "Failed to get git date"
return(date)
db.Meta.git_commit.compute = getGitCommit
db.Meta.git_date.compute = getGitDate
if db(db.Meta).count() == 0:
db.Meta.insert()
<html>
<body>
This is a test {{=var}}
This is a test {{=var}}<br><br>
This is commit <b>{{=meta.git_commit[:10] if len(meta.git_commit) > 10 else meta.git_commit}}</b> from <b>{{=meta.git_date}}</b> show on
<a href="https://git.noc.ruhr-uni-bochum.de/studienprojekt-ss20/lynchburg-server/-/commit/{{=meta.git_commit}}">GitLab</a><br>
Database from: {{=meta.creation}}
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment