X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=contrib%2Fgit-hooks%2Fcommit-msg;h=b93c79658f07be2008994bf5386f4197552bb6a4;hp=caf694c8630bcbf370a399666dc176f915e17be9;hb=4d6bff6be51ff6e336f73b2822ac5100254b9431;hpb=a2cadab9c5f641e2ceacd755b0123df77e5482b6;ds=sidebyside diff --git a/contrib/git-hooks/commit-msg b/contrib/git-hooks/commit-msg index caf694c..b93c796 100755 --- a/contrib/git-hooks/commit-msg +++ b/contrib/git-hooks/commit-msg @@ -19,6 +19,7 @@ init() { readonly SAVE="$(basename $ORIGINAL).$(date +%Y%m%d.%H%M%S)" readonly SIGNOFF="Signed-off-by:" readonly CHANGEID="Change-Id:" + readonly FIXES="Fixes:" readonly TESTPARAMS="Test-Parameters:" readonly INNOCUOUS=$(echo \ Acked-by \ @@ -29,8 +30,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 +43,7 @@ init() { HAS_BODY=false HAS_SIGNOFF=false HAS_CHANGEID=false + NEEDS_FIRST_LINE=true IS_WRAPPING_UP=false @@ -98,6 +100,21 @@ function do_changeid() { HAS_CHANGEID=true } +function do_testparams() { + ck_wrapup + + grep -q mdsfilesystemtype <<< $LINE && + error "mdsfilesystemtype is deprecated, use mdtfilesystemtype" +} + +function do_fixes() { + ck_wrapup + + local commit=$(awk '{ print $2 }' <<<$LINE) + git describe --tags $commit 2>&1 | grep "[Nn]ot a valid" && + error "has invalid $FIXES commit hash" +} + # All "innocuous" lines specify a person and email address # function do_innocuous() { @@ -111,7 +128,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 +143,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,39 +184,40 @@ usage() { exec 1>&2 cat <<- EOF - See http://wiki.whamcloud.com/display/PUB/Commit+Comments + See https://wiki.whamcloud.com/display/PUB/Commit+Comments for full details. An example valid commit comment is: LU-nnn component: short description of change under 64 columns The "component:" should be a lower-case single-word subsystem of the - Lustre code that best encompasses the change being made. Examples of - components include modules like: llite, lov, lmv, osc, mdc, ldlm, lnet, - ptlrpc, mds, oss, osd, ldiskfs, libcfs, socklnd, o2iblnd; functional - subsystems like: recovery, quota, grant; and auxilliary areas like: - build, tests, docs. This list is not exhaustive, but is a guideline. - - The commit comment should contain a detailed explanation of the change - being made. This can be as long as you'd like. Please give details - of what problem was solved (including error messages or problems that - were seen), a good high-level description of how it was solved, and - which parts of the code were changed (including important functions - that were changed, if this is useful to understand the patch, and - for easier searching). Wrap lines at/under $WIDTH_REG columns. - - Finish the comment with a blank line and a blank-line-free - sign off section: + Lustre code best covering the patch. Example components include: + llite, lov, lmv, osc, mdc, ldlm, lnet, ptlrpc, mds, oss, osd, + ldiskfs, libcfs, socklnd, o2iblnd; recovery, quota, grant; + build, tests, docs. This list is not exhaustive, but a guideline. + + The comment body should explan the change being made. This can be + as long as needed. Please include details of the problem that was + solved (including error messages that were seen), a good high-level + description of how it was solved, and which parts of the code were + changed (including important functions that were changed, if this is + useful to understand the patch, and for easier searching). + Performance patches should quanify the improvements being seen. + Wrap lines at/under $WIDTH_REG columns. + + Finish the comment with a blank line followed by the signoff section: $SIGNOFF Your Real Name $CHANGEID Ixxxx(added automatically if missing)xxxx - The "$CHANGEID" line should only be there when updating a previous - commit/submission. Copy the one from the original commit. + The "$CHANGEID" line should only be present when updating a previous + commit/submission. Copy the $CHANGEID from the original commit. It + will automatically be added by the Git commit-msg hook if missing. - The "sign off section" may also include several other tag lines: + The "signoff section" may optionally include other tag lines: $(for T in $(tr '|' ' ' <<< "$INNOCUOUS"); do \ echo " $T: Some Person "; \ done) + $FIXES git_commit_hash ("optional summary of original broken patch") $TESTPARAMS optional additional test parameters {Organization}-bug-id: associated external change identifier EOF @@ -213,13 +232,18 @@ 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 ;; + $FIXES* ) do_fixes ;; + $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 +275,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 ;;