This is an automated email from the ASF dual-hosted git repository.
aw pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/yetus.git
The following commit(s) were added to refs/heads/main by this push:
new a6dcbfb YETUS-1017. Rework post-processing comparison to de-duplicate
code (#147)
a6dcbfb is described below
commit a6dcbfb189d09f5317b2ce85ebea62aca3510b1d
Author: Allen Wittenauer <[email protected]>
AuthorDate: Tue Oct 6 20:28:58 2020 -0700
YETUS-1017. Rework post-processing comparison to de-duplicate code (#147)
Signed-off-by: Roman Shaposhnik <[email protected]>
---
precommit/src/main/shell/test-patch.d/buf.sh | 35 +------
precommit/src/main/shell/test-patch.d/cc.sh | 2 +-
precommit/src/main/shell/test-patch.d/checkmake.sh | 36 +------
precommit/src/main/shell/test-patch.d/golang.sh | 2 +-
precommit/src/main/shell/test-patch.d/golangci.sh | 35 +------
precommit/src/main/shell/test-patch.d/hadolint.sh | 80 +++------------
precommit/src/main/shell/test-patch.d/java.sh | 8 +-
precommit/src/main/shell/test-patch.d/jshint.sh | 39 +------
.../src/main/shell/test-patch.d/markdownlint.sh | 39 +------
.../src/main/shell/test-patch.d/perlcritic.sh | 37 +------
precommit/src/main/shell/test-patch.d/pylint.sh | 50 ++++-----
precommit/src/main/shell/test-patch.d/revive.sh | 38 +------
precommit/src/main/shell/test-patch.d/rubocop.sh | 36 +------
precommit/src/main/shell/test-patch.d/scala.sh | 6 +-
.../src/main/shell/test-patch.d/shellcheck.sh | 39 +------
precommit/src/main/shell/test-patch.d/shelldocs.sh | 37 +------
precommit/src/main/shell/test-patch.d/yamllint.sh | 41 +-------
precommit/src/main/shell/test-patch.sh | 114 ++++++++++++++++++++-
18 files changed, 189 insertions(+), 485 deletions(-)
diff --git a/precommit/src/main/shell/test-patch.d/buf.sh
b/precommit/src/main/shell/test-patch.d/buf.sh
index 6462c56..37960d9 100755
--- a/precommit/src/main/shell/test-patch.d/buf.sh
+++ b/precommit/src/main/shell/test-patch.d/buf.sh
@@ -297,12 +297,6 @@ function buflint_preapply
function buflint_postapply
{
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
-
if ! verify_needed_test buflint; then
return 0
fi
@@ -323,31 +317,10 @@ function buflint_postapply
"${PATCH_DIR}/patch-buflint-result.txt" \
buf > "${PATCH_DIR}/diff-patch-buflint.txt"
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-buflint-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-buflint-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-buflint.txt" | "${AWK}"
'{print $1}')
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 buflint \
- "@@BASE@@/diff-patch-buflint.txt" \
- "${BUILDMODEMSG} ${statstring}"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 buflint "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 buflint "" "There were no new buf lint issues."
- return 0
+ root_postlog_compare \
+ buflint \
+ "${PATCH_DIR}/branch-buflint-result.txt" \
+ "${PATCH_DIR}/patch-buflint-result.txt"
}
function buflint_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/cc.sh
b/precommit/src/main/shell/test-patch.d/cc.sh
index 02bac8b..4b31065 100755
--- a/precommit/src/main/shell/test-patch.d/cc.sh
+++ b/precommit/src/main/shell/test-patch.d/cc.sh
@@ -54,7 +54,7 @@ function cc_compile
fi
if [[ ${codebase} = patch ]]; then
- generic_postlog_compare compile cc "${multijdkmode}"
+ module_postlog_compare compile cc "${multijdkmode}"
fi
}
diff --git a/precommit/src/main/shell/test-patch.d/checkmake.sh
b/precommit/src/main/shell/test-patch.d/checkmake.sh
index 3f83bf5..9c4316c 100755
--- a/precommit/src/main/shell/test-patch.d/checkmake.sh
+++ b/precommit/src/main/shell/test-patch.d/checkmake.sh
@@ -123,13 +123,6 @@ function checkmake_calcdiffs
function checkmake_postapply
{
- declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
-
if ! verify_needed_test checkmake; then
return 0
fi
@@ -144,33 +137,10 @@ function checkmake_postapply
checkmake_exec patch
- calcdiffs \
- "${PATCH_DIR}/branch-checkmake-result.txt" \
- "${PATCH_DIR}/patch-checkmake-result.txt" \
+ root_postlog_compare \
checkmake \
- > "${PATCH_DIR}/diff-patch-checkmake.txt"
- diffPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 3<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/diff-patch-checkmake.txt")
-
- # shellcheck disable=SC2016
- numPrepatch=$("${AWK}" -F: 'BEGIN {sum=0} 3<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/branch-checkmake-result.txt")
-
- # shellcheck disable=SC2016
- numPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 3<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/patch-checkmake-result.txt")
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 checkmake "@@BASE@@/diff-patch-checkmake.txt"
"${BUILDMODEMSG} ${statstring}"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 checkmake "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 checkmake "" "There were no new checkmake issues."
- return 0
+ "${PATCH_DIR}/branch-checkmake-result.txt" \
+ "${PATCH_DIR}/patch-checkmake-result.txt"
}
function checkmake_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/golang.sh
b/precommit/src/main/shell/test-patch.d/golang.sh
index 6722234..f2b9d7b 100755
--- a/precommit/src/main/shell/test-patch.d/golang.sh
+++ b/precommit/src/main/shell/test-patch.d/golang.sh
@@ -126,7 +126,7 @@ function golang_compile
fi
if [[ ${codebase} = patch ]]; then
- generic_postlog_compare compile golang "${multijdkmode}"
+ module_postlog_compare compile golang "${multijdkmode}"
fi
}
diff --git a/precommit/src/main/shell/test-patch.d/golangci.sh
b/precommit/src/main/shell/test-patch.d/golangci.sh
index 571c77c..1866784 100755
--- a/precommit/src/main/shell/test-patch.d/golangci.sh
+++ b/precommit/src/main/shell/test-patch.d/golangci.sh
@@ -140,12 +140,6 @@ function golangcilint_calcdiffs
function golangcilint_postapply
{
- declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
if ! verify_needed_test golangcilint; then
return 0
@@ -161,33 +155,10 @@ function golangcilint_postapply
golangcilint_exec patch
- calcdiffs \
- "${PATCH_DIR}/branch-golangcilint-result.txt" \
- "${PATCH_DIR}/patch-golangcilint-result.txt" \
+ root_postlog_compare \
golangcilint \
- > "${PATCH_DIR}/diff-patch-golangcilint.txt"
- diffPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 3<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/diff-patch-golangcilint.txt")
-
- # shellcheck disable=SC2016
- numPrepatch=$("${AWK}" -F: 'BEGIN {sum=0} 3<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/branch-golangcilint-result.txt")
-
- # shellcheck disable=SC2016
- numPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 3<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/patch-golangcilint-result.txt")
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 golangcilint "@@BASE@@/diff-patch-golangcilint.txt"
"${BUILDMODEMSG} ${statstring}"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 golangcilint "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 golangcilint "" "There were no new golangcilint issues."
- return 0
+ "${PATCH_DIR}/branch-golangcilint-result.txt" \
+ "${PATCH_DIR}/patch-golangcilint-result.txt"
}
function golangcilint_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/hadolint.sh
b/precommit/src/main/shell/test-patch.d/hadolint.sh
index 1ea4170..cef17f8 100755
--- a/precommit/src/main/shell/test-patch.d/hadolint.sh
+++ b/precommit/src/main/shell/test-patch.d/hadolint.sh
@@ -80,7 +80,17 @@ function hadolint_logic
for i in "${HADOLINT_CHECKFILES[@]}"; do
if [[ -f "${i}" ]]; then
- "${HADOLINT}" "${i}" >> "${PATCH_DIR}/${repostatus}-hadolint-result.txt"
+
+ ## transform from
+ ## filename:line\sCODE Text
+ ## to
+ ## filename:line:\sCODE text
+ ## so that built-in routines can get used
+
+ # shellcheck disable=SC2016
+ "${HADOLINT}" "${i}" \
+ | "${AWK}" '{printf "%s:",$1; $1=""; print $0}' \
+ >> "${PATCH_DIR}/${repostatus}-hadolint-result.txt"
fi
done
popd > /dev/null || return 1
@@ -103,44 +113,13 @@ function hadolint_preapply
return 0
}
-## filename:line\sCODE Text
function hadolint_calcdiffs
{
- declare branch=$1
- declare patch=$2
- declare tmp=${PATCH_DIR}/pl.$$.${RANDOM}
- declare j
-
- # first, pull out just the errors
- # shellcheck disable=SC2016
- "${AWK}" -F: '{print $NF}' "${branch}" | cut -d' ' -f2- > "${tmp}.branch"
-
- # shellcheck disable=SC2016
- "${AWK}" -F: '{print $NF}' "${patch}" | cut -d' ' -f2- > "${tmp}.patch"
-
- "${DIFF}" --unchanged-line-format="" \
- --old-line-format="" \
- --new-line-format="%dn " \
- "${tmp}.branch" \
- "${tmp}.patch" > "${tmp}.lined"
-
- # now, pull out those lines of the raw output
- # shellcheck disable=SC2013
- for j in $(cat "${tmp}.lined"); do
- head -"${j}" "${patch}" | tail -1
- done
-
- rm "${tmp}.branch" "${tmp}.patch" "${tmp}.lined" 2>/dev/null
+ error_calcdiffs "$@"
}
function hadolint_postapply
{
- declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
declare version
if ! verify_needed_test hadolint; then
@@ -157,40 +136,13 @@ function hadolint_postapply
hadolint_logic patch
- calcdiffs \
- "${PATCH_DIR}/branch-hadolint-result.txt" \
- "${PATCH_DIR}/patch-hadolint-result.txt" \
- hadolint \
- > "${PATCH_DIR}/diff-patch-hadolint.txt"
-
version=$("${HADOLINT}" --version)
add_version_data hadolint "${version##* v}"
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-hadolint-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-hadolint-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-hadolint.txt" | "${AWK}"
'{print $1}')
-
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 hadolint "@@BASE@@/diff-patch-hadolint.txt"
"${BUILDMODEMSG} ${statstring}"
- bugsystem_linecomments_queue "hadolint"
"${PATCH_DIR}/diff-patch-hadolint.txt"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 hadolint "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 hadolint "" "There were no new hadolint issues."
- return 0
+ root_postlog_compare \
+ hadolint \
+ "${PATCH_DIR}/branch-hadolint-result.txt" \
+ "${PATCH_DIR}/patch-hadolint-result.txt"
}
function hadolint_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/java.sh
b/precommit/src/main/shell/test-patch.d/java.sh
index c12f146..6ae7853 100755
--- a/precommit/src/main/shell/test-patch.d/java.sh
+++ b/precommit/src/main/shell/test-patch.d/java.sh
@@ -165,8 +165,8 @@ function javac_compile
fi
if [[ ${codebase} = patch ]]; then
- yetus_debug "javac: calling generic_postlog_compare compile javac
${multijdkmode}"
- generic_postlog_compare compile javac "${multijdkmode}"
+ yetus_debug "javac: calling module_postlog_compare compile javac
${multijdkmode}"
+ module_postlog_compare compile javac "${multijdkmode}"
fi
}
@@ -188,9 +188,9 @@ function javadoc_rebuild
fi
if [[ "${codebase}" = branch ]]; then
- generic_pre_handler javadoc "${multijdkmode}"
+ module_pre_handler javadoc "${multijdkmode}"
else
- generic_post_handler javadoc javadoc "${multijdkmode}" true
+ module_post_handler javadoc javadoc "${multijdkmode}" true
fi
}
diff --git a/precommit/src/main/shell/test-patch.d/jshint.sh
b/precommit/src/main/shell/test-patch.d/jshint.sh
index 591de0f..f7a8a5a 100755
--- a/precommit/src/main/shell/test-patch.d/jshint.sh
+++ b/precommit/src/main/shell/test-patch.d/jshint.sh
@@ -141,12 +141,6 @@ function jshint_calcdiffs
function jshint_postapply
{
- declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
declare version
if ! verify_needed_test jshint; then
@@ -166,37 +160,10 @@ function jshint_postapply
version=$("${JSHINT}" --version 2>&1)
add_version_data jshint "${version#*v}"
- calcdiffs \
- "${PATCH_DIR}/branch-jshint-result.txt" \
- "${PATCH_DIR}/patch-jshint-result.txt" \
+ root_postlog_compare \
jshint \
- > "${PATCH_DIR}/diff-patch-jshint.txt"
-
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-jshint-result.txt" | ${AWK} '{print
$1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-jshint-result.txt" | ${AWK} '{print
$1}')
-
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-jshint.txt" | ${AWK} '{print
$1}')
-
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 jshint "@@BASE@@/diff-patch-jshint.txt"
"${BUILDMODEMSG} ${statstring}"
- bugsystem_linecomments_queue "jshint" "${PATCH_DIR}/diff-patch-jshint.txt"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 jshint "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 jshint "" "There were no new jshint issues."
- return 0
+ "${PATCH_DIR}/branch-jshint-result.txt" \
+ "${PATCH_DIR}/patch-jshint-result.txt"
}
function jshint_precompile
diff --git a/precommit/src/main/shell/test-patch.d/markdownlint.sh
b/precommit/src/main/shell/test-patch.d/markdownlint.sh
index 8812e27..64453eb 100755
--- a/precommit/src/main/shell/test-patch.d/markdownlint.sh
+++ b/precommit/src/main/shell/test-patch.d/markdownlint.sh
@@ -96,12 +96,6 @@ function markdownlint_calcdiffs
function markdownlint_postapply
{
- declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
declare version
if ! verify_needed_test markdownlint; then
@@ -122,37 +116,10 @@ function markdownlint_postapply
version=$("${MARKDOWNLINT}" --version 2>&1)
add_version_data markdownlint "${version#* }"
- calcdiffs \
- "${PATCH_DIR}/branch-markdownlint-result.txt" \
- "${PATCH_DIR}/patch-markdownlint-result.txt" \
+ root_postlog_compare \
markdownlint \
- > "${PATCH_DIR}/diff-patch-markdownlint.txt"
-
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-markdownlint-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-markdownlint-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-markdownlint.txt" | "${AWK}"
'{print $1}')
-
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 markdownlint "@@BASE@@/diff-patch-markdownlint.txt"
"${BUILDMODEMSG} ${statstring}"
- bugsystem_linecomments_queue "markdownlint"
"${PATCH_DIR}/diff-patch-markdownlint.txt"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 markdownlint "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 markdownlint "" "There were no new markdownlint issues."
- return 0
+ "${PATCH_DIR}/branch-markdownlint-result.txt" \
+ "${PATCH_DIR}/patch-markdownlint-result.txt"
}
function markdownlint_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/perlcritic.sh
b/precommit/src/main/shell/test-patch.d/perlcritic.sh
index 75a5399..fa380c8 100755
--- a/precommit/src/main/shell/test-patch.d/perlcritic.sh
+++ b/precommit/src/main/shell/test-patch.d/perlcritic.sh
@@ -99,11 +99,6 @@ function perlcritic_calcdiffs
function perlcritic_postapply
{
declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
if ! verify_needed_test perlcritic; then
return 0
@@ -130,36 +125,10 @@ function perlcritic_postapply
PERLCRITIC_VERSION=$(${PERLCRITIC} --version 2>/dev/null)
add_version_data perlcritic "${PERLCRITIC_VERSION}"
- calcdiffs \
- "${PATCH_DIR}/branch-perlcritic-result.txt" \
- "${PATCH_DIR}/patch-perlcritic-result.txt" \
+ root_postlog_compare \
perlcritic \
- > "${PATCH_DIR}/diff-patch-perlcritic.txt"
-
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-perlcritic-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-perlcritic-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-perlcritic.txt" | "${AWK}"
'{print $1}')
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]]; then
- add_vote_table_v2 -1 perlcritic "@@BASE@@/diff-patch-perlcritic.txt"
"${BUILDMODEMSG} ${statstring}"
- bugsystem_linecomments_queue perlcritic
"@@BASE@@/diff-patch-perlcritic.txt"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 perlcritic "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 perlcritic "" "There were no new perlcritic issues."
- return 0
+ "${PATCH_DIR}/branch-perlcritic-result.txt" \
+ "${PATCH_DIR}/patch-perlcritic-result.txt"
}
function perlcritic_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/pylint.sh
b/precommit/src/main/shell/test-patch.d/pylint.sh
index 694b591..0da225f 100755
--- a/precommit/src/main/shell/test-patch.d/pylint.sh
+++ b/precommit/src/main/shell/test-patch.d/pylint.sh
@@ -86,6 +86,11 @@ function pylint_precheck
fi
}
+function pylint_calcdiffs
+{
+ column_calcdiffs "$@"
+}
+
function pylint_executor
{
declare repostatus=$1
@@ -147,11 +152,20 @@ function pylint_executor
pushd "${BASEDIR}" >/dev/null || return 1
for i in "${CHANGED_FILES[@]}"; do
if [[ ${i} =~ \.py$ && -f ${i} ]]; then
- "${PYLINT}" "${pylintopts[@]}" --msg-template='{path}:{line}:
[{msg_id}({symbol}), {obj}] {msg}' "${i}" \
- 2>>"${PATCH_DIR}/${pylintStderr}" | "${AWK}" '1<NR' >>
"${PATCH_DIR}/${repostatus}-pylint-result.txt"
+ "${PYLINT}" "${pylintopts[@]}" \
+ --msg-template='{path}:{line}:{column}:[{msg_id}({symbol}), {obj}]
{msg}' "${i}" \
+ >> "${PATCH_DIR}/${repostatus}-pylint-result.tmp" \
+ 2>>"${PATCH_DIR}/${pylintStderr}"
fi
done
+ # pylint likes to put extra headers and
+ # stuff, so need to look specifically for our content
+ "${GREP}" '^.*:.*:.*:' \
+ "${PATCH_DIR}/${repostatus}-pylint-result.tmp" \
+ > "${PATCH_DIR}/${repostatus}-pylint-result.txt"
+ rm "${PATCH_DIR}/${repostatus}-pylint-result.tmp"
+
if [[ -n "${oldpp}" ]]; then
export PYTHONPATH=${oldpp}
fi
@@ -168,7 +182,6 @@ function pylint_executor
return 0
}
-
function pylint_preapply
{
declare retval
@@ -187,12 +200,6 @@ function pylint_preapply
function pylint_postapply
{
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
-
if ! verify_needed_test pylint; then
return 0
fi
@@ -203,28 +210,11 @@ function pylint_postapply
PYLINT_VERSION=$("${PYLINT}" --version 2>/dev/null | "${GREP}" pylint |
"${AWK}" '{print $NF}')
add_version_data pylint "${PYLINT_VERSION%,}"
- calcdiffs "${PATCH_DIR}/branch-pylint-result.txt" \
- "${PATCH_DIR}/patch-pylint-result.txt" \
- pylint > "${PATCH_DIR}/diff-patch-pylint.txt"
- numPrepatch=$("${GREP}" -c '^.*:.*: \[.*\] '
"${PATCH_DIR}/branch-pylint-result.txt")
- numPostpatch=$("${GREP}" -c '^.*:.*: \[.*\] '
"${PATCH_DIR}/patch-pylint-result.txt")
- # Exclude Pylint messages from the information category to avoid false
positives (see YETUS-309).
- diffPostpatch=$("${GREP}" -c '^.*:.*: \[[^I].*\] '
"${PATCH_DIR}/diff-patch-pylint.txt")
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 pylint "@@BASE@@/diff-patch-pylint.txt"
"${BUILDMODEMSG} ${statstring}"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 pylint "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 pylint "" "There were no new pylint issues."
- return 0
+ root_postlog_compare \
+ pylint \
+ "${PATCH_DIR}/branch-pylint-result.txt" \
+ "${PATCH_DIR}/patch-pylint-result.txt"
}
function pylint_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/revive.sh
b/precommit/src/main/shell/test-patch.d/revive.sh
index e3d0a1e..0057945 100755
--- a/precommit/src/main/shell/test-patch.d/revive.sh
+++ b/precommit/src/main/shell/test-patch.d/revive.sh
@@ -72,7 +72,7 @@ function revive_exec
echo "Running revive against identified go files."
pushd "${BASEDIR}" >/dev/null || return 1
- args=('-formatter' 'default')
+ args=('-formatter' 'plain')
if [[ -f "${REVIVE_CONFIG}" ]]; then
args+=('-config' "${REVIVE_CONFIG}")
fi
@@ -120,13 +120,6 @@ function revive_calcdiffs
function revive_postapply
{
- declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
-
if ! verify_needed_test revive; then
return 0
fi
@@ -141,33 +134,10 @@ function revive_postapply
revive_exec patch
- calcdiffs \
- "${PATCH_DIR}/branch-revive-result.txt" \
- "${PATCH_DIR}/patch-revive-result.txt" \
+ root_postlog_compare \
revive \
- > "${PATCH_DIR}/diff-patch-revive.txt"
- diffPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 3<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/diff-patch-revive.txt")
-
- # shellcheck disable=SC2016
- numPrepatch=$("${AWK}" -F: 'BEGIN {sum=0} 3<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/branch-revive-result.txt")
-
- # shellcheck disable=SC2016
- numPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 3<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/patch-revive-result.txt")
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 revive "@@BASE@@/diff-patch-revive.txt"
"${BUILDMODEMSG} ${statstring}"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 revive "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 revive "" "There were no new revive issues."
- return 0
+ "${PATCH_DIR}/branch-revive-result.txt" \
+ "${PATCH_DIR}/patch-revive-result.txt"
}
function revive_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/rubocop.sh
b/precommit/src/main/shell/test-patch.d/rubocop.sh
index 6ad3d36..00c9885 100755
--- a/precommit/src/main/shell/test-patch.d/rubocop.sh
+++ b/precommit/src/main/shell/test-patch.d/rubocop.sh
@@ -121,13 +121,6 @@ function rubocop_calcdiffs
function rubocop_postapply
{
- declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
-
if ! verify_needed_test rubocop; then
return 0
fi
@@ -146,33 +139,10 @@ function rubocop_postapply
RUBOCOP_VERSION=$("${RUBOCOP}" -v | "${AWK}" '{print $NF}')
add_version_data rubocop "${RUBOCOP_VERSION}"
- calcdiffs \
- "${PATCH_DIR}/branch-rubocop-result.txt" \
- "${PATCH_DIR}/patch-rubocop-result.txt" \
+ root_postlog_compare \
rubocop \
- > "${PATCH_DIR}/diff-patch-rubocop.txt"
- diffPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/diff-patch-rubocop.txt")
-
- # shellcheck disable=SC2016
- numPrepatch=$("${AWK}" -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/branch-rubocop-result.txt")
-
- # shellcheck disable=SC2016
- numPostpatch=$("${AWK}" -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}'
"${PATCH_DIR}/patch-rubocop-result.txt")
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 rubocop "@@BASE@@/diff-patch-rubocop.txt"
"${BUILDMODEMSG} ${statstring}"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 rubocop "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 rubocop "" "There were no new rubocop issues."
- return 0
+ "${PATCH_DIR}/branch-rubocop-result.txt" \
+ "${PATCH_DIR}/patch-rubocop-result.txt"
}
function rubocop_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/scala.sh
b/precommit/src/main/shell/test-patch.d/scala.sh
index ba29136..e9d2236 100755
--- a/precommit/src/main/shell/test-patch.d/scala.sh
+++ b/precommit/src/main/shell/test-patch.d/scala.sh
@@ -94,7 +94,7 @@ function scalac_compile
fi
if [[ ${codebase} = patch ]]; then
- generic_postlog_compare compile scalac "${multijdkmode}"
+ module_postlog_compare compile scalac "${multijdkmode}"
fi
}
@@ -109,9 +109,9 @@ function scaladoc_rebuild
declare codebase=$1
if [[ "${codebase}" = branch ]]; then
- generic_pre_handler scaladoc false
+ module_pre_handler scaladoc false
else
- generic_post_handler scaladoc scaladoc false true
+ module_post_handler scaladoc scaladoc false true
fi
}
diff --git a/precommit/src/main/shell/test-patch.d/shellcheck.sh
b/precommit/src/main/shell/test-patch.d/shellcheck.sh
index 7e45f15..e1b683a 100755
--- a/precommit/src/main/shell/test-patch.d/shellcheck.sh
+++ b/precommit/src/main/shell/test-patch.d/shellcheck.sh
@@ -206,12 +206,6 @@ function shellcheck_calcdiffs
function shellcheck_postapply
{
- declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
if ! verify_needed_test shellcheck; then
return 0
@@ -227,37 +221,10 @@ function shellcheck_postapply
shellcheck_logic patch
- calcdiffs \
- "${PATCH_DIR}/branch-shellcheck-result.txt" \
- "${PATCH_DIR}/patch-shellcheck-result.txt" \
+ root_postlog_compare \
shellcheck \
- > "${PATCH_DIR}/diff-patch-shellcheck.txt"
-
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-shellcheck-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-shellcheck-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-shellcheck.txt" | "${AWK}"
'{print $1}')
-
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 shellcheck "@@BASE@@/diff-patch-shellcheck.txt"
"${BUILDMODEMSG} ${statstring}"
- bugsystem_linecomments_queue "shellcheck"
"${PATCH_DIR}/diff-patch-shellcheck.txt"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 shellcheck "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 shellcheck "" "There were no new shellcheck issues."
- return 0
+ "${PATCH_DIR}/branch-shellcheck-result.txt" \
+ "${PATCH_DIR}/patch-shellcheck-result.txt"
}
function shellcheck_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/shelldocs.sh
b/precommit/src/main/shell/test-patch.d/shelldocs.sh
index 5177278..f0c0dc7 100755
--- a/precommit/src/main/shell/test-patch.d/shelldocs.sh
+++ b/precommit/src/main/shell/test-patch.d/shelldocs.sh
@@ -131,11 +131,6 @@ function shelldocs_preapply
function shelldocs_postapply
{
declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
if ! verify_needed_test shelldocs; then
return 0
@@ -157,36 +152,10 @@ function shelldocs_postapply
fi
done
- calcdiffs \
- "${PATCH_DIR}/branch-shelldocs-result.txt" \
- "${PATCH_DIR}/patch-shelldocs-result.txt" \
+ root_postlog_compare \
shelldocs \
- > "${PATCH_DIR}/diff-patch-shelldocs.txt"
-
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-shelldocs-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-shelldocs-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-shelldocs.txt" | "${AWK}"
'{print $1}')
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 shelldocs "@@BASE@@/diff-patch-shelldocs.txt"
"${BUILDMODEMSG} ${statstring}"
- bugsystem_linecomments_queue "shelldocs"
"${PATCH_DIR}/diff-patch-shelldocs.txt"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 shelldocs "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 shelldocs "" "There were no new shelldocs issues."
- return 0
+ "${PATCH_DIR}/branch-shelldocs-result.txt" \
+ "${PATCH_DIR}/patch-shelldocs-result.txt"
}
function shelldocs_postcompile
diff --git a/precommit/src/main/shell/test-patch.d/yamllint.sh
b/precommit/src/main/shell/test-patch.d/yamllint.sh
index 505de07..4e00ea5 100755
--- a/precommit/src/main/shell/test-patch.d/yamllint.sh
+++ b/precommit/src/main/shell/test-patch.d/yamllint.sh
@@ -42,8 +42,6 @@ function yamllint_precheck
add_vote_table_v2 0 yamllint "" "yamllint was not available."
delete_test yamllint
fi
-
-
}
function yamllint_logic
@@ -97,12 +95,6 @@ function yamllint_calcdiffs
function yamllint_postapply
{
- declare i
- declare numPrepatch
- declare numPostpatch
- declare diffPostpatch
- declare fixedpatch
- declare statstring
declare version
if ! verify_needed_test yamllint; then
@@ -123,37 +115,10 @@ function yamllint_postapply
version=$("${YAMLLINT}" --version 2>&1)
add_version_data yamllint "${version#* }"
- calcdiffs \
- "${PATCH_DIR}/branch-yamllint-result.txt" \
- "${PATCH_DIR}/patch-yamllint-result.txt" \
+ root_postlog_compare \
yamllint \
- > "${PATCH_DIR}/diff-patch-yamllint.txt"
-
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-yamllint-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-yamllint-result.txt" | "${AWK}"
'{print $1}')
-
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-yamllint.txt" | "${AWK}"
'{print $1}')
-
-
- ((fixedpatch=numPrepatch-numPostpatch+diffPostpatch))
-
- statstring=$(generic_calcdiff_status "${numPrepatch}" "${numPostpatch}"
"${diffPostpatch}" )
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- add_vote_table_v2 -1 yamllint "@@BASE@@/diff-patch-yamllint.txt"
"${BUILDMODEMSG} ${statstring}"
- bugsystem_linecomments_queue "yamllint"
"${PATCH_DIR}/diff-patch-yamllint.txt"
- return 1
- elif [[ ${fixedpatch} -gt 0 ]]; then
- add_vote_table_v2 +1 yamllint "" "${BUILDMODEMSG} ${statstring}"
- return 0
- fi
-
- add_vote_table_v2 +1 yamllint "" "There were no new yamllint issues."
- return 0
+ "${PATCH_DIR}/branch-yamllint-result.txt" \
+ "${PATCH_DIR}/patch-yamllint-result.txt"
}
function yamllint_postcompile
diff --git a/precommit/src/main/shell/test-patch.sh
b/precommit/src/main/shell/test-patch.sh
index 8be9c3b..b1af396 100755
--- a/precommit/src/main/shell/test-patch.sh
+++ b/precommit/src/main/shell/test-patch.sh
@@ -2539,7 +2539,7 @@ function generic_logfilter
fi
}
-## @description Helper routine for plugins to do a pre-patch prun
+## @description Deprecated. Use module_pre_handler instead.
## @audience public
## @stability evolving
## @replaceable no
@@ -2549,6 +2549,19 @@ function generic_logfilter
## @return 0 on success
function generic_pre_handler
{
+ module_pre_handler "$@"
+}
+
+## @description Helper routine for plugins to do a pre-patch run
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param testype
+## @param multijdk
+## @return 1 on failure
+## @return 0 on success
+function module_pre_handler
+{
declare testtype=$1
declare multijdkmode=$2
declare result=0
@@ -2591,7 +2604,15 @@ function generic_pre_handler
return 0
}
-## @description Generic post-patch log handler
+## @description Deprecated. Use module_postlog_compare instead.
+## @audience public
+## @stability evolving
+function generic_postlog_compare
+{
+ module_postlog_compare "$@"
+}
+
+## @description Module post-patch log handler
## @audience public
## @stability evolving
## @replaceable no
@@ -2600,7 +2621,7 @@ function generic_pre_handler
## @param origlog
## @param testtype
## @param multijdkmode
-function generic_postlog_compare
+function module_postlog_compare
{
declare origlog=$1
declare testtype=$2
@@ -2688,6 +2709,89 @@ function generic_postlog_compare
return 0
}
+## @description Root-level post-patch log handler. Files should be
+## @description linecomments compatible!
+## @audience public
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+## @param testtype
+## @param branchlog
+## @param patchlog
+function root_postlog_compare
+{
+ declare testtype=$1
+ declare branchlog=$2
+ declare patchlog=$3
+ declare fn
+ declare -i numbranch=0
+ declare -i numpatch=0
+ declare -i addpatch=0
+ declare -i samepatch=0
+ declare -i fixedpatch=0
+ declare tmpvar
+
+ yetus_debug "${testtype}: ${branchlog} vs. ${patchlog}"
+
+ # if it was a new module, this won't exist.
+ if [[ ! -f "${branchlog}" ]]; then
+ touch "${branchlog}"
+ fi
+
+ if [[ ! -f "${patchlog}" ]]; then
+ touch "${patchlog}"
+ fi
+
+ if [[ "${BUILDMODE}" == "full" ]]; then
+ difflog="results-${testtype}.txt"
+ else
+ difflog="diff-${testtype}.txt"
+ fi
+
+ tmpvar=$(wc -l "${branchlog}")
+ numbranch="${tmpvar%% *}"
+ tmpvar=$(wc -l "${patchlog}")
+ numpatch="${tmpvar%% *}"
+
+ calcdiffs \
+ "${branchlog}" \
+ "${patchlog}" \
+ "${testtype}" \
+ > "${PATCH_DIR}/${difflog}"
+
+ tmpvar=$(wc -l "${PATCH_DIR}/${difflog}")
+ addpatch="${tmpvar%% *}"
+
+ ((fixedpatch=numbranch-numpatch+addpatch))
+
+ statstring=$(generic_calcdiff_status "${numbranch}" "${numpatch}"
"${addpatch}" )
+
+ if [[ ${addpatch} -gt 0 ]]; then
+ add_vote_table_v2 -1 "${testtype}" "@@BASE@@/${difflog}" "${BUILDMODEMSG}
${statstring}"
+ bugsystem_linecomments_queue "${testtype}" "${PATCH_DIR}/${difflog}"
+ return 1
+ elif [[ ${fixedpatch} -gt 0 ]]; then
+ add_vote_table_v2 +1 "${testtype}" "" "${BUILDMODEMSG} ${statstring}"
+ return 0
+ fi
+
+ if [[ "${BUILDMODE}" == "full" ]]; then
+ add_vote_table_v2 +1 "${testtype}" "" "No issues."
+ else
+ add_vote_table_v2 +1 "${testtype}" "" "No new issues."
+ fi
+ return 0
+}
+
+## @description Deprecated. Use module_post_handler instead.
+## @audience public
+## @stability evolving
+function generic_post_handler
+{
+ module_post_handler "$@"
+}
+
## @description Generic post-patch handler
## @audience public
## @stability evolving
@@ -2698,7 +2802,7 @@ function generic_postlog_compare
## @param testtype
## @param multijdkmode
## @param run commands
-function generic_post_handler
+function module_post_handler
{
declare origlog=$1
declare testtype=$2
@@ -2736,7 +2840,7 @@ function generic_post_handler
fi
fi
- generic_postlog_compare "${origlog}" "${testtype}" "${multijdkmode}"
+ module_postlog_compare "${origlog}" "${testtype}" "${multijdkmode}"
((result=result+$?))
done
JAVA_HOME=${savejavahome}