From 19901ed8b94fc13cf9b55bc892aa193865b6793c Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 26 Nov 2025 00:47:25 -0500 Subject: [PATCH] [FIX] script format: ignore git repo if not installed --- script/maintenance/format_file_to_commit.py | 37 ++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/script/maintenance/format_file_to_commit.py b/script/maintenance/format_file_to_commit.py index 30d72d1..27862a5 100755 --- a/script/maintenance/format_file_to_commit.py +++ b/script/maintenance/format_file_to_commit.py @@ -16,13 +16,17 @@ def execute_shell(cmd): def get_modified_files(): lst_cmd_git_status = ["git", "status", "--porcelain"] - lst_cmd_git_status_repo = [ - ".venv.erplibre/bin/repo", - "forall", - "-p", - "-c", - "git status -s", - ] + path_repo_bin = ".venv.erplibre/bin/repo" + if os.path.exists(path_repo_bin): + lst_cmd_git_status_repo = [ + path_repo_bin, + "forall", + "-p", + "-c", + "git status -s", + ] + else: + lst_cmd_git_status_repo = [] try: print(" ".join(lst_cmd_git_status)) result = subprocess.run( @@ -35,15 +39,18 @@ def get_modified_files(): lst_lines = [(".", lines_local)] - print(" ".join(lst_cmd_git_status_repo)) + if lst_cmd_git_status_repo: + print(" ".join(lst_cmd_git_status_repo)) - result = subprocess.run( - lst_cmd_git_status_repo, - capture_output=True, - text=True, - check=True, - ) - lines_project = result.stdout.strip().split("\n\n") + result = subprocess.run( + lst_cmd_git_status_repo, + capture_output=True, + text=True, + check=True, + ) + lines_project = result.stdout.strip().split("\n\n") + else: + lines_project = [] if os.path.isfile(".odoo-version"): with open(".odoo-version") as txt: