misc: Updated git-commit-msg.py to print rejected commit
authorBobby R. Bruce <bbruce@ucdavis.edu>
Mon, 10 Feb 2020 20:07:52 +0000 (12:07 -0800)
committerBobby R. Bruce <bbruce@ucdavis.edu>
Thu, 13 Feb 2020 21:28:20 +0000 (21:28 +0000)
A rejected commit is now printed to stdout. This adds an additional
level of security if the ".git/COMMIT_EDITMSG" is deleted/overwritten.

Jira: https://gem5.atlassian.net/browse/GEM5-321
Change-Id: I87d463f7c40024d68bf78705f0d02fcea9f0eeeb
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25343
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
util/git-commit-msg.py

index 1ce8aa1716e8c376232cde4aca4913e73bb24a25..9d958e85e0c1544008db4bba100ac38ce2527139 100755 (executable)
@@ -45,10 +45,19 @@ def _printErrorQuit(error_message):
             failure.
     """
     print(error_message)
+
+    print("The commit has been cancelled, but a copy of it can be found in "
+            + sys.argv[1] + " : ")
+
     print("""
-The commit has been canceled, but a copy of it can be found in
-.git/COMMIT_EDITMSG
+--------------------------------------------------------------------------
+    """)
+    print(open(sys.argv[1], "r").read())
+    print("""
+--------------------------------------------------------------------------
+    """)
 
+    print("""
 The first line of a commit must contain one or more gem5 tags separated by
 commas (see MAINTAINERS for the possible tags), followed by a colon and a
 commit title. There must be no leading nor trailing whitespaces.
@@ -67,7 +76,6 @@ e.g.:
 
     The packet class...
 """)
-    print("A copy of your commit message can be found in " + sys.argv[1])
     sys.exit(1)
 
 def _validateTags(commit_header):