From da5f6b5f4188d6b70c71f32c433f5c7b70706bab Mon Sep 17 00:00:00 2001
From: Mathieu Courtois <mathieu.courtois@edf.fr>
Date: Wed, 18 Dec 2024 18:38:18 +0100
Subject: [PATCH] [#34305] pre-push: improve message, only in src

---
 bin/hooks/git_hook_main        |  2 +-
 lib/hgaster/hooks/codeaster.py | 32 +++++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/bin/hooks/git_hook_main b/bin/hooks/git_hook_main
index 6258d02..556adc5 100755
--- a/bin/hooks/git_hook_main
+++ b/bin/hooks/git_hook_main
@@ -38,7 +38,7 @@ def main(repotype, repopath, hook, amend, *args):
         return OK
 
     if hook == "pre-push":
-        return run_ctest_minimal()
+        return run_ctest_minimal(repopath)
 
     logger.error(_("hook '{0}' is not defined").format(hook))
     return 1
diff --git a/lib/hgaster/hooks/codeaster.py b/lib/hgaster/hooks/codeaster.py
index 0b6687d..22a7e47 100644
--- a/lib/hgaster/hooks/codeaster.py
+++ b/lib/hgaster/hooks/codeaster.py
@@ -126,32 +126,42 @@ def aslint(repopath, paths=(), amend=False):
     return OK
 
 
-def run_ctest_minimal():
-    """Run a minimal list of testcases."""
+def run_ctest_minimal(repopath):
+    """Run a minimal list of testcases.
+
+    Arguments:
+        repopath (str): Repository path.
+    """
     from subprocess import call
 
+    from aslint.base_checkers import checkcontext
     from aslint.check_files import read_waf_parameters
     from aslint.config import ASCFG
 
-    logger.warning("Run a minimal list of testcases (for about 30 seconds).")
-    logger.info("NB: It will used the already installed version.")
-    try:
-        answ = input("Do you want to continue (y/[n], 'Ctrl+C' to abort push) ? ")
-    except KeyboardInterrupt:
-        return NOOK
-    if answ.lower() not in ("y", "o"):
-        logger.info("run_ctest skipped.")
+    checkcontext.reponame = get_repo_name(repopath)
+    if checkcontext.reponame != "src":
         return OK
 
+    logger.warning("Run a minimal list of testcases (for about 30 seconds).")
+
     builddir = ASCFG.get("waf.builddir")
     target = "release"
     if os.environ.get("BUILD") == "debug":
         builddir = "build/mpidebug" if osp.isdir("build/mpidebug") else "build/mpi"
         target = "debug"
     wafc4che = osp.join(builddir, "c4che", target + "_cache.py")
-
     c4che = read_waf_parameters(wafc4che)
     run_ctest = Path(c4che["BINDIR"]) / "run_ctest"
+
+    logger.info("NB: This version will be used: %s", run_ctest)
+    try:
+        answ = input("Do you want to continue (y/[n], 'Ctrl+C' to abort push) ? ")
+    except KeyboardInterrupt:
+        return NOOK
+    if answ.lower() not in ("y", "o"):
+        logger.info("run_ctest skipped.")
+        return OK
+
     cmd = [run_ctest, "-R", "(asrun0|mumps02b|supv002|vocab0|zzzz509j)", "--no-resutest"]
     if call(cmd):
         return NOOK
-- 
GitLab