TMP / Fixed "cmake not found" in pre-commit.py

This commit is contained in:
OLEGSHA 2023-03-12 20:17:45 +01:00
parent 2e61b990f7
commit 44ed00f76c

View File

@ -331,13 +331,8 @@ def parse_args():
def load_settings(): def load_settings():
"""Load values from pre-commit-settings.json.""" """Ensure pre-commit-settings.json exists and is loaded into memory."""
global settings global settings
global build_root
global git
global cmake
global clang_format_diff
global parallelism
path = get_settings_path() path = get_settings_path()
if os.path.exists(path): if os.path.exists(path):
@ -355,6 +350,15 @@ def load_settings():
} }
save_settings() save_settings()
def parse_settings():
"""Load values from settings and check their validity."""
global settings
global build_root
global git
global cmake
global clang_format_diff
global parallelism
build_root = settings['build_root'] build_root = settings['build_root']
parallelism = settings['parallelism'] parallelism = settings['parallelism']
@ -395,11 +399,13 @@ if __name__ == '__main__':
if action == 'set-build-info': if action == 'set-build-info':
set_build_info() set_build_info()
elif action == 'restore': elif action == 'restore':
parse_settings()
do_restore() do_restore()
indexed, unindexed = get_file_sets() indexed, unindexed = get_file_sets()
if indexed & unindexed: if indexed & unindexed:
unformat_project(indexed) unformat_project(indexed)
else: else:
parse_settings()
pre_commit() pre_commit()
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
fail('Command', *(repr(c) for c in e.cmd), fail('Command', *(repr(c) for c in e.cmd),