소스 검색

move git_status to sysinfo

w-e-w 1 년 전
부모
커밋
6a7042fe2f
2개의 변경된 파일6개의 추가작업 그리고 10개의 파일을 삭제
  1. 0 9
      modules/launch_utils.py
  2. 6 1
      modules/sysinfo.py

+ 0 - 9
modules/launch_utils.py

@@ -85,14 +85,6 @@ def git_tag():
             return "<none>"
             return "<none>"
 
 
 
 
-@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:
 def run(command, desc=None, errdesc=None, custom_env=None, live: bool = default_command_live) -> str:
     if desc is not None:
     if desc is not None:
         print(desc)
         print(desc)
@@ -453,7 +445,6 @@ def prepare_environment():
         exit(0)
         exit(0)
 
 
 
 
-
 def configure_for_tests():
 def configure_for_tests():
     if "--api" not in sys.argv:
     if "--api" not in sys.argv:
         sys.argv.append("--api")
         sys.argv.append("--api")

+ 6 - 1
modules/sysinfo.py

@@ -106,7 +106,7 @@ def get_dict():
         "Python": platform.python_version(),
         "Python": platform.python_version(),
         "Version": launch_utils.git_tag(),
         "Version": launch_utils.git_tag(),
         "Commit": launch_utils.commit_hash(),
         "Commit": launch_utils.commit_hash(),
-        "Git status": launch_utils.git_status(),
+        "Git status": git_status(paths_internal.script_path),
         "Script path": paths_internal.script_path,
         "Script path": paths_internal.script_path,
         "Data path": paths_internal.data_path,
         "Data path": paths_internal.data_path,
         "Extensions dir": paths_internal.extensions_dir,
         "Extensions dir": paths_internal.extensions_dir,
@@ -168,6 +168,11 @@ def run_git(path, *args):
         return str(e)
         return str(e)
 
 
 
 
+def git_status(path):
+    if (Path(path) / '.git').is_dir():
+        return run_git(paths_internal.script_path, 'status')
+
+
 def get_info_from_repo_path(path: Path):
 def get_info_from_repo_path(path: Path):
     is_repo = (path / '.git').is_dir()
     is_repo = (path / '.git').is_dir()
     return {
     return {