You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@yetus.apache.org by aw...@apache.org on 2021/11/05 18:58:18 UTC
[yetus] branch main updated: YETUS-1135. hadolint 2.x has ANSI
sequences in output (#234)
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 2c3a42e YETUS-1135. hadolint 2.x has ANSI sequences in output (#234)
2c3a42e is described below
commit 2c3a42e625eff94886ebbc095a8f42fc49f62773
Author: Allen Wittenauer <aw...@apache.org>
AuthorDate: Fri Nov 5 11:58:15 2021 -0700
YETUS-1135. hadolint 2.x has ANSI sequences in output (#234)
---
precommit/src/main/shell/plugins.d/hadolint.sh | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/precommit/src/main/shell/plugins.d/hadolint.sh b/precommit/src/main/shell/plugins.d/hadolint.sh
index cef17f8..7d45f61 100755
--- a/precommit/src/main/shell/plugins.d/hadolint.sh
+++ b/precommit/src/main/shell/plugins.d/hadolint.sh
@@ -21,6 +21,7 @@ add_test_type hadolint
HADOLINT_TIMER=0
HADOLINT=${HADOLINT:-$(command -v hadolint 2>/dev/null)}
+HADOLINT_VERSION=''
# files that are going to get hadolint'd
HADOLINT_CHECKFILES=()
@@ -66,6 +67,10 @@ function hadolint_precheck
fi
fi
+ HADOLINT_VERSION=$("${HADOLINT}" --version)
+ HADOLINT_VERSION=${HADOLINT_VERSION##* v}
+ add_version_data hadolint "${HADOLINT_VERSION}"
+
if [[ ! "${LANG}" =~ UTF-8 ]]; then
yetus_error "WARNING: hadolint may fail without UTF-8 locale setting."
fi
@@ -75,9 +80,16 @@ function hadolint_logic
{
declare repostatus=$1
declare i
+ declare -a args
pushd "${BASEDIR}" >/dev/null || return 1
+ if [[ "${HADOLINT_VERSION}" =~ ^[01] ]]; then
+ args=()
+ else
+ args=(--no-color)
+ fi
+
for i in "${HADOLINT_CHECKFILES[@]}"; do
if [[ -f "${i}" ]]; then
@@ -88,7 +100,9 @@ function hadolint_logic
## so that built-in routines can get used
# shellcheck disable=SC2016
- "${HADOLINT}" "${i}" \
+ "${HADOLINT}" \
+ "${args[@]}" \
+ "${i}" \
| "${AWK}" '{printf "%s:",$1; $1=""; print $0}' \
>> "${PATCH_DIR}/${repostatus}-hadolint-result.txt"
fi
@@ -120,8 +134,6 @@ function hadolint_calcdiffs
function hadolint_postapply
{
- declare version
-
if ! verify_needed_test hadolint; then
return 0
fi
@@ -136,9 +148,6 @@ function hadolint_postapply
hadolint_logic patch
- version=$("${HADOLINT}" --version)
- add_version_data hadolint "${version##* v}"
-
root_postlog_compare \
hadolint \
"${PATCH_DIR}/branch-hadolint-result.txt" \