From f6acfd396821573a8ea2368b91555ebd8e118abe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 21 Feb 2023 14:30:44 -0500
Subject: [PATCH] build.py: fix hooks installation with --init

+ add clang-format to client-qt/.git/hooks
+ only modify daemon and ignore other modules as not using gerrit.

Change-Id: Ib7f498d3a960da7ff739311409ad922c9976d5d7
---
 build.py | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/build.py b/build.py
index 489d2b48b..4ed2468ca 100755
--- a/build.py
+++ b/build.py
@@ -303,26 +303,11 @@ def run_dependencies(args):
 
 
 def run_init():
-    # Extract modules path from '.gitmodules' file
-    module_names = []
-    with open('.gitmodules') as fd:
-        for line in fd.readlines():
-            if line.startswith('[submodule "'):
-                module_names.append(line[line.find('"')+1:line.rfind('"')])
-
-    subprocess.run(["git", "submodule", "update", "--init"], check=True)
-    subprocess.run(["git", "submodule", "foreach",
-                    "git checkout master && git pull"], check=True)
-
-    for name in module_names:
-        hooks_dir = f'.git/modules/{name}/hooks'
+    hooks_directories = ['.git/hooks/', f'.git/modules/daemon/hooks']
+    for hooks_dir in hooks_directories:
         if not os.path.exists(hooks_dir):
             os.makedirs(hooks_dir)
-        copy_file("./extras/scripts/commit-msg", f'{hooks_dir}/commit-msg')
-
-    module_names_to_format = ['daemon']
-    for name in module_names_to_format:
-        hooks_dir = f'.git/modules/{name}/hooks'
+        copy_file("./extras/scripts/commit-msg", hooks_dir + "/commit-msg")
         execute_script(['./extras/scripts/format.sh --install %(path)s'],
                        {"path": hooks_dir})
 
-- 
GitLab