Whamcloud - gitweb
LU-883 build: allow blank after signoff, email fix
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 15 Dec 2011 07:16:20 +0000 (00:16 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 19 Jan 2012 23:41:21 +0000 (18:41 -0500)
Allow blank lines after the signoff section, since there will usually
be a blank line between the signoff and the checkpatch.pl output.

Improve the EMAILPAT regex to detect bad email addresses that do not
have a full name (at least 2 parts) and a full domain (also with
at least 2 parts).

Allow a generic "{Organization}-bug-id:" line in the signoff section
to allow linking the patch commit into arbitrary bug databases for
ease of tracking patches.

Add test cases for all of these changes.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Iaf14f6c985d3dd4837064d29071bd9acd8031d67
Reviewed-on: http://review.whamcloud.com/1867
Reviewed-by: <bruce.korb@gmail.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
build/Makefile
build/commit-msg
build/commit.ok_bugid [new file with mode: 0644]
build/commit.ok_dupsign
build/commit.ok_innocuous [new file with mode: 0644]
build/commit.ok_signoff
build/test-commit-msg.sh

index 6f9b4b3..0e5c8d4 100644 (file)
@@ -56,8 +56,8 @@ echoarch:
        echo $(ARCH) >$(ARCHFILE)
 
 TESTS := $(wildcard commit.*)
        echo $(ARCH) >$(ARCHFILE)
 
 TESTS := $(wildcard commit.*)
-check-commit :
+check-commit:
        SHELL="$(SHELL)" $(SHELL) test-commit-msg.sh $(TESTS)
 
        SHELL="$(SHELL)" $(SHELL) test-commit-msg.sh $(TESTS)
 
-check : check-commit
+check: check-commit
 .PHONY: check-commit
 .PHONY: check-commit
index 331db3d..02d704d 100755 (executable)
@@ -22,9 +22,9 @@ init() {
         readonly INNOCUOUS=$(echo \
                         Acked-by \
                         Tested-by \
         readonly INNOCUOUS=$(echo \
                         Acked-by \
                         Tested-by \
-                        CC \
                         Reported-by \
                         Reviewed-by \
                         Reported-by \
                         Reviewed-by \
+                        CC \
                 | tr ' ' '|')
         readonly WIDTH_SUM=64
         readonly WIDTH_REG=70
                 | tr ' ' '|')
         readonly WIDTH_SUM=64
         readonly WIDTH_REG=70
@@ -33,7 +33,7 @@ init() {
 
         # Identify a name followed by an email address.
         #
 
         # Identify a name followed by an email address.
         #
-        readonly EMAILPAT=$'[ \t]*[a-zA-Z][^<>]*[ \t]<[^@ \t>]+@[^@ \t>]+>'
+        readonly EMAILPAT=$'[ \t]*[^<> ]* [^<>]* <[^@ \t>]+@[a-zA-Z0-9.-]+\.[a-z]+>'
 
         HAS_ERROR=false
         HAS_SUMMARY=false
 
         HAS_ERROR=false
         HAS_SUMMARY=false
@@ -77,7 +77,7 @@ function do_signoff() {
         ck_wrapup
         # Signed-off-by: First Last <email@host.domain>
         local txt=$(echo "${LINE#*: }" | grep -E "${EMAILPAT}")
         ck_wrapup
         # Signed-off-by: First Last <email@host.domain>
         local txt=$(echo "${LINE#*: }" | grep -E "${EMAILPAT}")
-        if (( ${#txt} == 0 )) ; then
+        if (( ${#txt} == 0 )); then
                 error "$SIGNOFF line requires name and email address"
         else
                 HAS_SIGNOFF=true # require at least one
                 error "$SIGNOFF line requires name and email address"
         else
                 HAS_SIGNOFF=true # require at least one
@@ -92,7 +92,7 @@ function do_changeid() {
         # capital "I" plus 40 hex digits
         #
         local txt=$(echo "$LINE" | grep "^$CHANGEID I[0-9a-fA-F]\{40\}\$")
         # capital "I" plus 40 hex digits
         #
         local txt=$(echo "$LINE" | grep "^$CHANGEID I[0-9a-fA-F]\{40\}\$")
-        (( ${#txt} > 0 )) || \
+        (( ${#txt} > 0 )) ||
                 error "has invalid $CHANGEID line for Gerrit tracking"
 
         HAS_CHANGEID=true
                 error "has invalid $CHANGEID line for Gerrit tracking"
 
         HAS_CHANGEID=true
@@ -111,23 +111,23 @@ function do_default_line() {
                 error "invalid signoff section line"
                 return
         }
                 error "invalid signoff section line"
                 return
         }
-        if (( NUM == 1 )) ; then
+        if (( NUM == 1 )); then
                 HAS_JIRA_COMPONENT=$(echo "$LINE" | grep "$JIRA_FMT_A")
 
                 HAS_JIRA_COMPONENT=$(echo "$LINE" | grep "$JIRA_FMT_A")
 
-                if (( ${#HAS_JIRA_COMPONENT} == 0 )) ; then
+                if (( ${#HAS_JIRA_COMPONENT} == 0 )); then
                         HAS_JIRA=$(echo "$LINE" | grep "$JIRA_FMT_B")
                         HAS_JIRA=$(echo "$LINE" | grep "$JIRA_FMT_B")
-                        if (( ${#HAS_JIRA} > 0 )) ; then
+                        if (( ${#HAS_JIRA} > 0 )); then
                                 error "has no component in summary."
                         else
                                 error "missing JIRA ticket number."
                         fi
                                 error "has no component in summary."
                         else
                                 error "missing JIRA ticket number."
                         fi
-                elif (( ${#LINE} > WIDTH_SUM )) ; then
+                elif (( ${#LINE} > WIDTH_SUM )); then
                         error "summary longer than $WIDTH_SUM columns."
                 else
                         HAS_SUMMARY=true
                 fi
 
                         error "summary longer than $WIDTH_SUM columns."
                 else
                         HAS_SUMMARY=true
                 fi
 
-        elif (( ${#LINE} > WIDTH_REG )) ; then
+        elif (( ${#LINE} > WIDTH_REG )); then
                 error "has line longer than $WIDTH_REG columns."
         elif ! $HAS_BODY && ! $HAS_LAST_BLANK; then
                 error "has no blank line after summary."
                 error "has line longer than $WIDTH_REG columns."
         elif ! $HAS_BODY && ! $HAS_LAST_BLANK; then
                 error "has no blank line after summary."
@@ -148,7 +148,7 @@ new_changeid() {
                         git rev-parse HEAD 2>/dev/null
                         grep -v "^$SIGNOFF" "$ORIGINAL" | git stripspace -s
                 } | git hash-object --stdin)
                         git rev-parse HEAD 2>/dev/null
                         grep -v "^$SIGNOFF" "$ORIGINAL" | git stripspace -s
                 } | git hash-object --stdin)
-        (( ${#NEWID} > 0 )) || \
+        (( ${#NEWID} > 0 )) ||
                 die "git hash-object failed for $CHANGEID:"
 
         echo "$CHANGEID I$NEWID"
                 die "git hash-object failed for $CHANGEID:"
 
         echo "$CHANGEID I$NEWID"
@@ -193,14 +193,15 @@ usage() {
        $SIGNOFF Your Real Name <your_email@domain.name>
        $CHANGEID Ixxxx(added automatically if missing)xxxx
 
        $SIGNOFF Your Real Name <your_email@domain.name>
        $CHANGEID Ixxxx(added automatically if missing)xxxx
 
-       Included in the "sign off section" may be any of several other
-       tag lines:
-           $(echo "$INNOCUOUS" | tr '|' ' ')
        The "$CHANGEID" line should only be there when updating a previous
        The "$CHANGEID" line should only be there when updating a previous
-       commit/submission.  Copy the one from that commit.
+       commit/submission.  Copy the one from the original commit.
+
+       The "sign off section" may also include several other tag lines:
+       $(for T in $(tr '|' ' ' <<< "$INNOCUOUS"); do echo "  $T: <email>"; done
+       {Organization}-bug-id: associated ticket identifier
        EOF
 
        EOF
 
-        mv "$ORIGINAL" "$SAVE" && \
+        mv "$ORIGINAL" "$SAVE" &&
                 echo "$0: saved original commit comment to $SAVE" 1>&2
 }
 
                 echo "$0: saved original commit comment to $SAVE" 1>&2
 }
 
@@ -214,9 +215,8 @@ while IFS= read -u3 LINE; do
         $CHANGEID* )  do_changeid  ;;
 
         "")
         $CHANGEID* )  do_changeid  ;;
 
         "")
-                $IS_WRAPPING_UP && \
-                        error "blank lines not allowed in signoff section"
                 HAS_LAST_BLANK=true
                 HAS_LAST_BLANK=true
+                $IS_WRAPPING_UP && continue
                 ;;
 
         \#*)
                 ;;
 
         \#*)
@@ -240,9 +240,14 @@ while IFS= read -u3 LINE; do
                 ;;
 
         *)
                 ;;
 
         *)
-                if [[ "$LINE" =~ ^($INNOCUOUS): ]] ; then
+                if [[ "$LINE" =~ ^($INNOCUOUS): ]]; then
                         do_innocuous
                         do_innocuous
-                else
+               elif [[ "$LINE" =~ ^[A-Za-z0-9_-]+-bug-id: ]]; then
+                       ck_wrapup
+               else
+                       # Allow arbitrary external bug identifiers for tracking.
+                       # I can't seem to find a pattern for the "case" that
+                       # checks for "*-bug-id", so this is checked here.
                         do_default_line
                 fi
                 ;;
                         do_default_line
                 fi
                 ;;
diff --git a/build/commit.ok_bugid b/build/commit.ok_bugid
new file mode 100644 (file)
index 0000000..7448f24
--- /dev/null
@@ -0,0 +1,9 @@
+LU-553 build: improve checks for commit-msg
+
+message
+body
+
+Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
+Change-Id: I0123456789012345678901234567890123456789
+Xyratex-bug-id: MRP-123
+Oracle-bug-id: 12345
index d1206a9..b7b47e2 100644 (file)
@@ -12,4 +12,4 @@ temporary file, so that it can be edited and re-used, instead of
 having to recreate it each time, or fetch it from .git/COMMIT_MSG.
 
 Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
 having to recreate it each time, or fetch it from .git/COMMIT_MSG.
 
 Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
-Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
+Signed-off-by: Andrew Dillinger <adillinger@wild-west.com>
diff --git a/build/commit.ok_innocuous b/build/commit.ok_innocuous
new file mode 100644 (file)
index 0000000..091e171
--- /dev/null
@@ -0,0 +1,12 @@
+LU-553 build: improve checks for commit-msg
+
+message
+body
+
+Signed-off-by: Orin Scrivello, DDS <ouch@icu4dk.com>
+Change-Id: I0123456789012345678901234567890123456789
+Acked-by:    Joe Doaks <Joe.Doaks@sample.info>
+Tested-by:   Jane Pain <Jane.Pain@sample.co.uk>
+CC:          Your Mother <mutha@home.net>
+Reported-by: Anony Mouse <mickey@steamboat.biz>
+Reviewed-by: Joe Hacker <root@p0wned.com>
index 7e1b288..0a0f01a 100644 (file)
@@ -4,9 +4,11 @@ message
 body
 
 Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
 body
 
 Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
+Signed-off-by: Andreas Eric Dilger <adilger@dilger.ca>
+Signed-off-by: Andreas Eric Dilger <andreas.dilger@mail.my-domain.za>
+Signed-off-by: Andreas Smyth Esq. III <asmyth_iii@my-domain-3.co.uk>
 Change-Id: I0123456789012345678901234567890123456789
 Change-Id: I0123456789012345678901234567890123456789
-Acked-by:    Joe Doaks <Joe.Doaks@sample.com>
-Tested-by:   Jane Pain <Jane.Pain@sample.com>
-CC:          Your Mother <mom@sample.com>
-Reported-by: Anony Mouse <mickey@sample.com>
-Reviewed-by: Joe Hacker <joey@hacker-industries.com>
+
+# total: 0 errors, 0 warnings, 36 lines checked
+#
+# Your patch has no obvious style problems and is ready for submission.
index 04f2f08..899f366 100755 (executable)
@@ -38,4 +38,4 @@ do
         esac
 done
 
         esac
 done
 
-rm -f $TEMPFILE
+rm -f $TEMPFILE $TEMPFILE.*