Skip to content
Snippets Groups Projects
Commit 876e2804 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

add script

parent 84d8b31b
No related branches found
No related tags found
1 merge request!17Version
""" Scripts for Poetry
"""
import json
import os
import re
import sys
from subprocess import check_call
......@@ -10,6 +12,33 @@ from subprocess import check_call
_project = "thermod"
def app_version():
import git
version_file = open(f"{_project}/resources/app-version.json", "w+")
try:
repo = git.Repo(".")
gitHash = repo.head.commit.hexsha
version = repo.git.describe(tags=True, first_parent=True, always=True)
url = os.environ.get("CI_PROJECT_URL", repo.remotes.origin.url)
if "gitlab-ci-token" in url:
url = re.sub(r"gitlab-ci-token\:.*@", "", url)
version_info = dict(
gitHash=gitHash,
projectName="ncm-ws",
url=url,
version=version,
)
version_file.write(json.dumps(version_info, indent=2))
except Exception as error:
print("Failed to create version file. Writing blank file.")
version_file.write(json.dumps("{}"))
def setup():
# Setup GitHooks
os.system("git config core.hookspath .githooks")
......@@ -41,8 +70,8 @@ def help():
def format_check():
# Check code format
check_call(["isort", "--check", "--diff", ".", "--skip", ".poetry"])
check_call(["black", "--check", "--diff", ".", "--exclude", ".poetry"])
check_call(["isort", "--check", "--diff", ".", "--skip", ".venv"])
check_call(["black", "--check", "--diff", ".", "--exclude", ".venv"])
def format():
......
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