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 a6731e16 YETUS-1202. plug-ins cannot use filefilter to build lists of
files (#291)
a6731e16 is described below
commit a6731e16fecd1d751220a15c3f9aefd21f28a508
Author: Allen Wittenauer <[email protected]>
AuthorDate: Wed Oct 12 08:08:51 2022 -0700
YETUS-1202. plug-ins cannot use filefilter to build lists of files (#291)
---
.../in-progress/precommit/advanced.html.md | 4 ++-
precommit/src/main/shell/plugins.d/hadolint.sh | 8 ++---
precommit/src/main/shell/plugins.d/shelldocs.sh | 13 ++++++++
precommit/src/main/shell/plugins.d/yamllint.sh | 35 +++++++++++-----------
4 files changed, 36 insertions(+), 24 deletions(-)
diff --git
a/asf-site-src/source/documentation/in-progress/precommit/advanced.html.md
b/asf-site-src/source/documentation/in-progress/precommit/advanced.html.md
index a6a36750..5257321a 100644
--- a/asf-site-src/source/documentation/in-progress/precommit/advanced.html.md
+++ b/asf-site-src/source/documentation/in-progress/precommit/advanced.html.md
@@ -62,7 +62,9 @@ This function call registers the `pluginname` so that
test-patch knows that it e
function pluginname_filefilter
```
-defines the filefilter for the `pluginname` plug-in.
+defines the filefilter for the `pluginname` plug-in. This function determines
if the plug-in should
+execute given the filename. If more extensive analysis is required, execute
`add_test` and do that
+work later as there is a chance the file has not been added to the file system
yet.
Similarly, there are other functions that may be defined during the test-patch
run:
diff --git a/precommit/src/main/shell/plugins.d/hadolint.sh
b/precommit/src/main/shell/plugins.d/hadolint.sh
index 61a72814..b052f741 100755
--- a/precommit/src/main/shell/plugins.d/hadolint.sh
+++ b/precommit/src/main/shell/plugins.d/hadolint.sh
@@ -23,16 +23,12 @@ HADOLINT_TIMER=0
HADOLINT=${HADOLINT:-$(command -v hadolint 2>/dev/null)}
HADOLINT_VERSION=''
-# files that are going to get hadolint'd
-HADOLINT_CHECKFILES=()
-
function hadolint_filefilter
{
declare filename=$1
if [[ ${filename} =~ Dockerfile ]]; then
add_test hadolint
- yetus_add_array_element HADOLINT_CHECKFILES "${filename}"
fi
}
@@ -95,8 +91,8 @@ function hadolint_logic
args=(--no-color)
fi
- for i in "${HADOLINT_CHECKFILES[@]}"; do
- if [[ -f "${i}" ]]; then
+ for i in "${CHANGED_FILES[@]}"; do
+ if [[ "${i}" =~ Dockerfile ]] && [[ -f "${i}" ]]; then
## transform from
## filename:line\sCODE Text
diff --git a/precommit/src/main/shell/plugins.d/shelldocs.sh
b/precommit/src/main/shell/plugins.d/shelldocs.sh
index 1457c16b..55ad5c96 100755
--- a/precommit/src/main/shell/plugins.d/shelldocs.sh
+++ b/precommit/src/main/shell/plugins.d/shelldocs.sh
@@ -148,6 +148,19 @@ function shelldocs_postapply
echo "Running shelldocs against all identifiable shell scripts"
# we re-check this in case one has been added
for i in $(shelldocs_private_findbash); do
+
+ skipflag="false"
+
+ for excludepath in "${EXCLUDE_PATHS[@]}"; do
+ if [[ "${i}" =~ ${excludepath} ]]; then
+ skipflag="true"
+ fi
+ done
+
+ if [[ "${skipflag}" == "true" ]]; then
+ continue
+ fi
+
if [[ -f ${i} ]]; then
"${SHELLDOCS}" --input "${i}" --lint >>
"${PATCH_DIR}/patch-shelldocs-result.txt" 2>&1
fi
diff --git a/precommit/src/main/shell/plugins.d/yamllint.sh
b/precommit/src/main/shell/plugins.d/yamllint.sh
index 0eb6daa9..eeb55a69 100755
--- a/precommit/src/main/shell/plugins.d/yamllint.sh
+++ b/precommit/src/main/shell/plugins.d/yamllint.sh
@@ -22,9 +22,6 @@ add_test_type yamllint
YAMLLINT_TIMER=0
YAMLLINT=${YAMLLINT:-$(command -v yamllint 2>/dev/null)}
-# files that are going to get yamllint'd
-YAMLLINT_CHECKFILES=()
-
function yamllint_filefilter
{
declare filename=$1
@@ -32,7 +29,6 @@ function yamllint_filefilter
if [[ ${filename} =~ \.yaml$ ]] ||
[[ ${filename} =~ \.yml$ ]]; then
add_test yamllint
- yetus_add_array_element YAMLLINT_CHECKFILES "${filename}"
fi
}
@@ -54,19 +50,24 @@ function yamllint_logic
pushd "${BASEDIR}" >/dev/null || return 1
- for i in "${YAMLLINT_CHECKFILES[@]}"; do
- if [[ -f "${i}" ]]; then
- fn=""
- while read -r; do
- if [[ -z "${fn}" ]]; then
- fn=$REPLY
- elif [[ -n "${REPLY}" ]]; then
- # (space)line:col(space)error/warning(space)text
- output=$(echo "${REPLY}" | awk '{$1=$1":"; $2=$2":"; print $0;}')
- # fn:line:col:(space)error/warning:(space)text
- echo "${fn}:${output}" >>
"${PATCH_DIR}/${repostatus}-yamllint-result.txt"
- fi
- done < <("${YAMLLINT}" "${i}")
+ for i in "${CHANGED_FILES[@]}"; do
+
+ if [[ ${i} =~ \.yaml$ ]] ||
+ [[ ${i} =~ \.yml$ ]]; then
+
+ if [[ -f "${i}" ]]; then
+ fn=""
+ while read -r; do
+ if [[ -z "${fn}" ]]; then
+ fn=$REPLY
+ elif [[ -n "${REPLY}" ]]; then
+ # (space)line:col(space)error/warning(space)text
+ output=$(echo "${REPLY}" | awk '{$1=$1":"; $2=$2":"; print $0;}')
+ # fn:line:col:(space)error/warning:(space)text
+ echo "${fn}:${output}" >>
"${PATCH_DIR}/${repostatus}-yamllint-result.txt"
+ fi
+ done < <("${YAMLLINT}" "${i}")
+ fi
fi
done
popd > /dev/null || return 1