[v6,3/7] git-p4: add p4-pre-submit exit text
diff mbox series

Message ID ae1a4614ee4e08704d7731f47311963a4c01e2bd.1581691486.git.gitgitgadget@gmail.com
State New
Headers show
Series
  • git-p4: add hooks for p4-changelist
Related show

Commit Message

Philippe Blain via GitGitGadget Feb. 14, 2020, 2:44 p.m. UTC
From: Ben Keene <seraphire@gmail.com>

When the p4-pre-submit exits with a non-zero exit code, the application
will abort the process with no additional information presented to the
user. This can be confusing for new users as it may not be clear that
the p4-pre-submit action caused the error.

Add text to explain why the program aborted the submit action.

Signed-off-by: Ben Keene <seraphire@gmail.com>
---
 git-p4.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/git-p4.py b/git-p4.py
index 4eccea3fa58..b1c86678fc6 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2405,7 +2405,15 @@  def run(self, args):
             sys.exit("number of commits (%d) must match number of shelved changelist (%d)" %
                      (len(commits), num_shelves))
 
-        if not run_git_hook("p4-pre-submit"):
+        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)
 
         #