Whamcloud - gitweb
LU-3434 scripts: check for mdsfilesystemtype= option
[fs/lustre-release.git] / contrib / git-hooks / commit-msg
index caf694c..d28e40b 100755 (executable)
@@ -29,8 +29,8 @@ init() {
                | tr ' ' '|')
        readonly WIDTH_SUM=62
        readonly WIDTH_REG=70
-       readonly JIRA_FMT_A="^[A-Z]\{2,5\}-[0-9]\{1,5\} [-a-z0-9]\{2,11\}: "
-       readonly JIRA_FMT_B="^[A-Z]\{2,5\}-[0-9]\{1,5\} "
+       readonly JIRA_FMT_A="^[A-Z]\{2,9\}-[0-9]\{1,5\} [-a-z0-9]\{2,11\}: "
+       readonly JIRA_FMT_B="^[A-Z]\{2,9\}-[0-9]\{1,5\} "
 
        # Identify a name followed by an email address.
        #
@@ -42,6 +42,7 @@ init() {
        HAS_BODY=false
        HAS_SIGNOFF=false
        HAS_CHANGEID=false
+       NEEDS_FIRST_LINE=true
 
        IS_WRAPPING_UP=false
 
@@ -98,6 +99,13 @@ function do_changeid() {
        HAS_CHANGEID=true
 }
 
+function do_testparams() {
+       ck_wrapup
+
+       grep -q mdsfilesystemtype <<< $LINE &&
+               error "mdsfilesystemtype is deprecated, use mdtfilesystemtype"
+}
+
 # All "innocuous" lines specify a person and email address
 #
 function do_innocuous() {
@@ -111,7 +119,7 @@ function do_default_line() {
                error "invalid signoff section line"
                return
        }
-       if (( NUM == 1 )); then
+       if ${NEEDS_FIRST_LINE}; then
                HAS_JIRA_COMPONENT=$(echo "$LINE" | grep "$JIRA_FMT_A")
 
                if (( ${#HAS_JIRA_COMPONENT} == 0 )); then
@@ -126,6 +134,7 @@ function do_default_line() {
                else
                        HAS_SUMMARY=true
                fi
+               NEEDS_FIRST_LINE=false
 
        elif (( ${#LINE} > WIDTH_REG )); then
                error "has line longer than $WIDTH_REG columns."
@@ -166,7 +175,7 @@ usage() {
         exec 1>&2
         cat <<- EOF
 
-       See http://wiki.whamcloud.com/display/PUB/Commit+Comments
+       See https://wiki.hpdd.intel.com/display/PUB/Commit+Comments
        for full details.  An example valid commit comment is:
 
        LU-nnn component: short description of change under 64 columns
@@ -213,13 +222,17 @@ exec 3< "$ORIGINAL" 4> "$REVISED" || exit 1
 while IFS= read -u3 LINE; do
        ((NUM += 1))
        case "$LINE" in
-       $SIGNOFF* )   do_signoff   ;;
-       $CHANGEID* )  do_changeid  ;;
-       $TESTPARAMS* ) ck_wrapup   ;;
+       $SIGNOFF* )   do_signoff     ;;
+       $CHANGEID* )  do_changeid    ;;
+       $TESTPARAMS* ) do_testparams ;;
 
        "")
                HAS_LAST_BLANK=true
-               $IS_WRAPPING_UP && continue
+
+               # Do not emit blank lines before summary line or after
+               # the tag lines have begun.
+               #
+               ${NEEDS_FIRST_LINE} || ${IS_WRAPPING_UP} && continue
                ;;
 
        \#*)
@@ -251,12 +264,13 @@ while IFS= read -u3 LINE; do
        *)
                if [[ "$LINE" =~ ^($INNOCUOUS): ]]; then
                        do_innocuous
+
                elif [[ "$LINE" =~ ^[A-Za-z0-9_-]+-bug-id: ]]; then
+                       # Allow arbitrary external bug identifiers for tracking.
+                       #
                        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
                ;;