@matheusbsbs / matheus-bagliano / commits / aa8b766a13
Fork 0

git-p4: add p4-pre-submit exit text

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ben Keene committed Feb 11, 2020 at 18:58 UTC aa8b766a1393070fc85a585b875a4a4f34a08573
1 file changed +9 -1
git-p4.py
+9 -1
@@ -2405,7 +2405,15 @@ class P4Submit(Command, P4UserMap):
2405 sys.exit("number of commits (%d) must match number of shelved changelist (%d)" %
2406 (len(commits), num_shelves))
2407
2408 - if not run_git_hook("p4-pre-submit"):
2408 + try:
2409 + if not run_git_hook("p4-pre-submit"):
2410 + print("\nThe p4-pre-submit hook failed, aborting the submit.\n\nYou can skip " \
2411 + "this pre-submission check by adding\nthe command line option '--no-verify', " \
2412 + "however,\nthis will also skip the p4-changelist hook as well.")
2413 + sys.exit(1)
2414 + except Exception as e:
2415 + print("\nThe p4-pre-submit hook failed, aborting the submit.\n\nThe hook failed "\
2416 + "with the error '{0}'".format(e.message) )
2417 sys.exit(1)
2418
2419 #