From 27947a79d619eac5ce40b3f2db62d422313d12f6 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:56:06 +0900 Subject: [PATCH] git status --- modules/launch_utils.py | 8 ++++++++ modules/sysinfo.py | 11 +++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/launch_utils.py b/modules/launch_utils.py index e22da4ec6..0688f4826 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -85,6 +85,14 @@ def git_tag(): return "" +@lru_cache() +def git_status(): + try: + return subprocess.check_output([git, "-C", script_path, "status"], shell=False, encoding='utf8').strip() + except Exception as e: + return str(e) + + def run(command, desc=None, errdesc=None, custom_env=None, live: bool = default_command_live) -> str: if desc is not None: print(desc) diff --git a/modules/sysinfo.py b/modules/sysinfo.py index 65d4e3c98..52617573b 100644 --- a/modules/sysinfo.py +++ b/modules/sysinfo.py @@ -1,13 +1,12 @@ import json import os import sys - +import subprocess import platform import hashlib import re -import launch -from modules import paths_internal, timer, shared, extensions, errors +from modules import paths_internal, timer, shared, extensions, errors, launch_utils checksum_token = "DontStealMyGamePlz__WINNERS_DONT_USE_DRUGS__DONT_COPY_THAT_FLOPPY" environment_whitelist = { @@ -89,7 +88,6 @@ def get_ram_info(): def get_packages(): try: - import subprocess return subprocess.check_output([sys.executable, '-m', 'pip', 'freeze', '--all']).decode("utf8").splitlines() except Exception as pip_error: try: @@ -104,8 +102,9 @@ def get_dict(): res = { "Platform": platform.platform(), "Python": platform.python_version(), - "Version": launch.git_tag(), - "Commit": launch.commit_hash(), + "Version": launch_utils.git_tag(), + "Commit": launch_utils.commit_hash(), + "Git status": launch_utils.git_status(), "Script path": paths_internal.script_path, "Data path": paths_internal.data_path, "Extensions dir": paths_internal.extensions_dir,