Thread (1 message) 1 message, 1 author, 2020-02-10

Re: [PATCH v4 2/6] git-p4: create new function run_git_hook

From: Junio C Hamano <hidden>
Date: 2020-02-10 22:24:54

"Ben Keene via GitGitGadget" [off-list ref] writes:
quoted hunk
@@ -2337,12 +2405,15 @@ def run(self, args):
             sys.exit("number of commits (%d) must match number of shelved changelist (%d)" %
                      (len(commits), num_shelves))
 
-        hooks_path = gitConfig("core.hooksPath")
-        if len(hooks_path) <= 0:
-            hooks_path = os.path.join(os.environ.get("GIT_DIR", ".git"), "hooks")
-
-        hook_file = os.path.join(hooks_path, "p4-pre-submit")
-        if os.path.isfile(hook_file) and os.access(hook_file, os.X_OK) and subprocess.call([hook_file]) != 0:
+        try:
+            if not run_git_hook("p4-pre-submit"):
+                print("\nThe p4-pre-submit hook failed, aborting the submit.\n\nYou can skip " \
+                    "this pre-submission check by adding\nthe command line option '--no-verify', " \
+                    "however,\nthis will also skip the p4-changelist hook as well.")
+                sys.exit(1)
+        except Exception as e:
+            print("\nThe p4-pre-submit hook failed, aborting the submit.\n\nThe hook failed "\
+                "with the error '{0}'".format(e.message) )
             sys.exit(1)
If I am reading the patches correctly, we do not have the
"--no-verify" option at this point in the series.  Shouldn't this
step limit itself to replace the removed lines we see above
with just a singlie liner:

	if not run_git_hook("p4-pre-submit"):
		sys.exit(1)

instead?

Also, af the end of these 6-patch series, I do not see a change to
guard this part of the code with "if not self.no_verify" like the
previous round did.

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help