yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject yetus git commit: YETUS-498. shelllcheck needs to have -x support
Date Mon, 27 Mar 2017 20:06:50 GMT
Repository: yetus
Updated Branches:
  refs/heads/master fdeee7bb8 -> 4028e6c18


YETUS-498. shelllcheck needs to have -x support

Signed-off-by: Allen Wittenauer <aw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/4028e6c1
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/4028e6c1
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/4028e6c1

Branch: refs/heads/master
Commit: 4028e6c1807b297103d34e64179a92d595b10eaf
Parents: fdeee7b
Author: Allen Wittenauer <aw@apache.org>
Authored: Wed Mar 22 18:34:27 2017 -0700
Committer: Allen Wittenauer <aw@apache.org>
Committed: Mon Mar 27 12:01:49 2017 -0700

----------------------------------------------------------------------
 precommit/test-patch.d/shellcheck.sh | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/4028e6c1/precommit/test-patch.d/shellcheck.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/shellcheck.sh b/precommit/test-patch.d/shellcheck.sh
index 0e053e3..dd9783c 100755
--- a/precommit/test-patch.d/shellcheck.sh
+++ b/precommit/test-patch.d/shellcheck.sh
@@ -17,6 +17,7 @@
 add_test_type shellcheck
 
 SHELLCHECK_TIMER=0
+SHELLCHECK_X=true
 
 SHELLCHECK=${SHELLCHECK:-$(which shellcheck 2>/dev/null)}
 
@@ -45,6 +46,14 @@ function shellcheck_precheck
   if ! verify_command "shellcheck" "${SHELLCHECK}"; then
     add_vote_table 0 shellcheck "Shellcheck was not available."
     delete_test shellcheck
+  else
+    # shellcheck disable=SC2016
+    SHELLCHECK_VERSION=$("${SHELLCHECK}" --version | "${GREP}" version: | "${AWK}" '{print
$NF}')
+
+    # versions less than 0.4.1 do not support -x
+    if [[ ${SHELLCHECK_VERSION} =~ 0.[0-3].[0-9] || ${SHELLCHECK_VERSION} = 0.4.0 ]]; then
+      SHELLCHECK_X=false
+    fi
   fi
 
   if [[ -z "${LANG}" ]]; then
@@ -114,13 +123,15 @@ function shellcheck_preapply
   pushd "${BASEDIR}" >/dev/null
   for i in $(shellcheck_private_findbash); do
     if [[ -f ${i} ]]; then
-      ${SHELLCHECK} -f gcc "${i}" >> "${PATCH_DIR}/branch-shellcheck-result.txt"
+      if [[ "${SHELLCHECK_X}" = true ]]; then
+        "${SHELLCHECK}" -x -f gcc "${i}" >> "${PATCH_DIR}/branch-shellcheck-result.txt"
+      else
+        "${SHELLCHECK}" -f gcc "${i}" >> "${PATCH_DIR}/branch-shellcheck-result.txt"
+      fi
     fi
   done
   popd > /dev/null
 
-  # shellcheck disable=SC2016
-  SHELLCHECK_VERSION=$(${SHELLCHECK} --version | ${GREP} version: | ${AWK} '{print $NF}')
   msg="v${SHELLCHECK_VERSION}"
   if [[ ${SHELLCHECK_VERSION} =~ 0.[0-3].[0-5] ]]; then
     msg="${msg} (This is an old version that has serious bugs. Consider upgrading.)"
@@ -169,7 +180,11 @@ function shellcheck_postapply
   # we re-check this in case one has been added
   for i in $(shellcheck_private_findbash); do
     if [[ -f ${i} ]]; then
-      ${SHELLCHECK} -f gcc "${i}" >> "${PATCH_DIR}/patch-shellcheck-result.txt"
+      if [[ "${SHELLCHECK_X}" = true ]]; then
+        "${SHELLCHECK}" -x -f gcc "${i}" >> "${PATCH_DIR}/patch-shellcheck-result.txt"
+      else
+        "${SHELLCHECK}" -f gcc "${i}" >> "${PATCH_DIR}/patch-shellcheck-result.txt"
+      fi
     fi
   done
 


Mime
View raw message