Skip to content

Commit

Permalink
launch.py: make git_tag() and commit_hash() work even when WEBUI_LAUN…
Browse files Browse the repository at this point in the history
…CH_LIVE_OUTPUT
  • Loading branch information
akx committed May 12, 2023
1 parent 54c84e6 commit 55d222a
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import importlib.util
import platform
import json
from functools import lru_cache

from modules import cmd_args
from modules.paths_internal import script_path, extensions_dir
Expand All @@ -14,8 +15,6 @@
python = sys.executable
git = os.environ.get('GIT', "git")
index_url = os.environ.get('INDEX_URL', "")
stored_commit_hash = None
stored_git_tag = None
dir_repos = "repositories"

# Whether to default to printing command output
Expand Down Expand Up @@ -56,32 +55,20 @@ def check_python_version():
""")


@lru_cache()
def commit_hash():
global stored_commit_hash

if stored_commit_hash is not None:
return stored_commit_hash

try:
stored_commit_hash = run(f"{git} rev-parse HEAD").strip()
return subprocess.check_output(f"{git} rev-parse HEAD", encoding='utf8').strip()
except Exception:
stored_commit_hash = "<none>"

return stored_commit_hash
return "<none>"


@lru_cache()
def git_tag():
global stored_git_tag

if stored_git_tag is not None:
return stored_git_tag

try:
stored_git_tag = run(f"{git} describe --tags").strip()
return subprocess.check_output(f"{git} describe --tags", encoding='utf8').strip()
except Exception:
stored_git_tag = "<none>"

return stored_git_tag
return "<none>"


def run(command, desc=None, errdesc=None, custom_env=None, live: bool = default_command_live) -> str:
Expand Down

0 comments on commit 55d222a

Please sign in to comment.