Skip to content

Commit

Permalink
#348: use git hash for app version (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasPickering authored and dtracers committed Oct 2, 2019
1 parent 4bb5c74 commit 1961c94
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend/initial_setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import os
import shutil
import subprocess
from typing import Dict, List, Tuple

from flask import Flask, render_template, g, request, redirect, send_from_directory
Expand Down Expand Up @@ -194,7 +195,8 @@ def __init__(self):
@classmethod
def get_version(cls):
try:
# TODO use some sort of git lookup to get information
return "0.0.1"
except:
return "0.0.1"
return subprocess.check_output([
'git', 'rev-parse', '--short', 'HEAD'
]).decode().strip()
except subprocess.CalledProcessError:
return 'unknown'
11 changes: 11 additions & 0 deletions tests/server_tests/backend_utils_tests/initial_setup_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import re

from backend.initial_setup import CalculatedServer


class Test_initial_setup:
def test_get_version(self):
# git needs to be in the environment for this
assert re.compile(r"[0-9a-fA-F]{7}").match(
CalculatedServer.get_version()
)

0 comments on commit 1961c94

Please sign in to comment.