-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
autodetect current version of the application
- Loading branch information
1 parent
16f21f4
commit cef18e7
Showing
3 changed files
with
27 additions
and
12 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
|
||
import os | ||
import json | ||
import subprocess | ||
from csskp.settings import BASE_DIR | ||
|
||
|
||
def get_version(request): | ||
try: | ||
with open(os.path.join(BASE_DIR,'VERSION.json'), 'r') as json_file: | ||
data = json.load(json_file) | ||
version = "{}.{}.{}".format(data['major'], data['minor'], | ||
data['hotfix']) | ||
except: | ||
version = "0.0.0" | ||
version = ( | ||
os.environ.get("PKGVER") | ||
or subprocess.run(["git", | ||
"-C", | ||
BASE_DIR, | ||
"describe", | ||
"--tags"], stdout=subprocess.PIPE) | ||
.stdout.decode() | ||
.strip() | ||
) | ||
version = version.split("-") | ||
if len(version) == 1: | ||
app_version = version[0] | ||
version_url = "https://github.com/CASES-LU/Fit4Cybersecurity/releases/tag/{}".format( | ||
version[0] | ||
) | ||
else: | ||
app_version = "{} - {}".format(version[0], version[2][1:]) | ||
version_url = "https://github.com/CASES-LU/Fit4Cybersecurity/commits/{}".format( | ||
version[2][1:] | ||
) | ||
return { | ||
'app_version': version | ||
'app_version': app_version, | ||
'version_url': version_url | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters