Except handling for 'Git not found' in about page

This commit is contained in:
Elias
2018-01-24 16:14:29 +02:00
parent a4367bbc9d
commit 283d5b566e
+14 -4
View File
@@ -86,15 +86,25 @@ def logout_view(request, *args, **kwargs):
@require_http_methods(["GET"])
def about_view(request, *args, **kwargs):
"""Render about page."""
repo = git.init_repo()
latest_commit = repo.git("rev-parse HEAD").decode('utf-8')
latest_date = repo.git("show -s --format=%ci " + latest_commit).decode('utf-8')
latest_tag = repo.git("describe --tags " + repo.git("rev-list --tags --max-count=1").decode('utf-8')).decode('utf-8')
latest_commit = "Not found"
latest_date = "Not found"
latest_tag = "Not found"
try:
repo = git.init_repo()
latest_commit = repo.git("rev-parse HEAD").decode('utf-8')
latest_date = repo.git("show -s --format=%ci " + latest_commit).decode('utf-8')
latest_tag = repo.git("describe --tags " + repo.git("rev-list --tags --max-count=1").decode('utf-8')).decode('utf-8')
except:
pass
context = {
'commit': latest_commit,
'date': latest_date,
'tag': latest_tag
}
return render(request, "about.html", context)