This is an automated email from the ASF dual-hosted git repository.
aw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yetus.git
The following commit(s) were added to refs/heads/master by this push:
new ae68743 YETUS-794. exclusion support
ae68743 is described below
commit ae687437c33377d90066a2b40ff1ea7a2c2d940f
Author: Allen Wittenauer <[email protected]>
AuthorDate: Wed Feb 13 06:55:47 2019 -0800
YETUS-794. exclusion support
Signed-off-by: Sean Busbey <[email protected]>
---
precommit/src/main/shell/core.d/01-common.sh | 2 ++
precommit/src/main/shell/core.d/change-analysis.sh | 32 ++++++++++++++++++++++
.../shell/test-patch-docker/launch-test-patch.sh | 5 ++++
precommit/src/main/shell/test-patch.d/author.sh | 24 ++++++++++------
.../src/main/shell/test-patch.d/whitespace.sh | 13 ++++++++-
precommit/src/main/shell/test-patch.sh | 20 ++++++++++++++
6 files changed, 86 insertions(+), 10 deletions(-)
diff --git a/precommit/src/main/shell/core.d/01-common.sh
b/precommit/src/main/shell/core.d/01-common.sh
index 23faaac..d5e5c32 100755
--- a/precommit/src/main/shell/core.d/01-common.sh
+++ b/precommit/src/main/shell/core.d/01-common.sh
@@ -29,6 +29,8 @@ function common_defaults
BUILDTOOLS=()
#shellcheck disable=SC2034
EXEC_MODES=()
+ #shellcheck disable=SC2034
+ EXCLUDE_PATHS=()
ROBOTTYPE=""
LOAD_SYSTEM_PLUGINS=true
#shellcheck disable=SC2034
diff --git a/precommit/src/main/shell/core.d/change-analysis.sh
b/precommit/src/main/shell/core.d/change-analysis.sh
index 916dd29..98bfc83 100755
--- a/precommit/src/main/shell/core.d/change-analysis.sh
+++ b/precommit/src/main/shell/core.d/change-analysis.sh
@@ -77,6 +77,38 @@ function find_changed_files
popd >/dev/null || return 1
}
+## @description Apply the EXCLUDE_PATHS to CHANGED_FILES
+## @audience private
+## @stability stable
+## @replaceable no
+## @return None; sets ${CHANGED_FILES[@]}
+function exclude_paths_from_changed_files
+{
+ declare f
+ declare p
+ declare strip
+ declare -a a
+
+ if [[ -n "${EXCLUDE_PATHS_FILE}" ]]; then
+ yetus_file_to_array EXCLUDE_PATHS "${EXCLUDE_PATHS_FILE}"
+ fi
+
+ for f in "${CHANGED_FILES[@]}"; do
+ strip=false
+ for p in "${EXCLUDE_PATHS[@]}"; do
+ if [[ "${f}" =~ ${p} ]]; then
+ strip=true
+ echo "${f}" >> "${PATCH_DIR}/excluded.txt"
+ fi
+ done
+ if [[ ${strip} = false ]]; then
+ a+=("${f}")
+ fi
+ done
+
+ CHANGED_FILES=("${a[@]}")
+}
+
## @description Check for directories to skip during
## @description changed module calcuation
## @description requires $MODULE_SKIPDIRS to be set
diff --git a/precommit/src/main/shell/test-patch-docker/launch-test-patch.sh
b/precommit/src/main/shell/test-patch-docker/launch-test-patch.sh
index f1f190d..70e0993 100755
--- a/precommit/src/main/shell/test-patch-docker/launch-test-patch.sh
+++ b/precommit/src/main/shell/test-patch-docker/launch-test-patch.sh
@@ -53,6 +53,11 @@ fi
PATCH_DIR=$(yetus_abs "${PATCH_DIR}")
OVERWRITEARGS+=("--patch-dir=${PATCH_DIR}")
OVERWRITEARGS+=("--user-plugins=${PATCH_DIR}/precommit/user-plugins")
+
+if [[ -f "${PATCH_DIR}/precommit/excluded.txt" ]]; then
+ OVERWRITEARGS+=("--excludes=${PATCH_DIR}/precommit/excluded.txt")
+fi
+
if [[ -f "${PATCH_DIR}/precommit/unit_test_filter_file.txt" ]]; then
OVERWRITEARGS+=("--unit-test-filter-file=${PATCH_DIR}/precommit/unit_test_filter_file.txt")
fi
diff --git a/precommit/src/main/shell/test-patch.d/author.sh
b/precommit/src/main/shell/test-patch.d/author.sh
index dccd504..f958dc2 100755
--- a/precommit/src/main/shell/test-patch.d/author.sh
+++ b/precommit/src/main/shell/test-patch.d/author.sh
@@ -104,7 +104,7 @@ function author_patchfile
fi
done
- ${GREP} -i -n '^[^-].*@author' "${patchfile}" >>
"${PATCH_DIR}/author-tags.txt"
+ "${GREP}" -i -n '^[^-].*@author' "${patchfile}" >>
"${PATCH_DIR}/author-tags.txt"
author_generic
}
@@ -119,7 +119,7 @@ function author_postcompile
{
# shellcheck disable=SC2155
declare -r appname=$(basename "${BASH_SOURCE-$0}")
- declare fn
+ declare -a globalignore
if [[ "${BUILDMODE}" != full ]]; then
return
@@ -129,19 +129,25 @@ function author_postcompile
start_clock
+ if [[ -n "${EXCLUDE_PATHS_FILE}" ]]; then
+ globalignore=("${GREP}" "-v" "-E" "-f" "${EXCLUDE_PATHS_FILE}")
+ else
+ globalignore=("cat")
+ fi
+
"${GIT}" grep -n -I --extended-regexp -i -e '^[^-].*@author' \
- | ${GREP} -v "${appname}" \
+ | "${GREP}" -v "${appname}" \
+ | "${globalignore[@]}" \
>> "${PATCH_DIR}/author-tags-git.txt"
if [[ -z "${AUTHOR_IGNORE_LIST[0]}" ]]; then
cp -p "${PATCH_DIR}/author-tags-git.txt" "${PATCH_DIR}/author-tags.txt"
else
- cp -p "${PATCH_DIR}/author-tags-git.txt" "${PATCH_DIR}/author-tags.1"
- for fn in "${AUTHOR_IGNORE_LIST[@]}"; do
- ${GREP} -v -E "^${fn}" "${PATCH_DIR}/author-tags.1" >>
"${PATCH_DIR}/author-tags.2"
- mv "${PATCH_DIR}/author-tags.2" "${PATCH_DIR}/author-tags.1"
- done
- mv "${PATCH_DIR}/author-tags.1" "${PATCH_DIR}/author-tags.txt"
+ printf "^%s\n" "${AUTHOR_IGNORE_LIST[@]}" >
"${PATCH_DIR}/author-tags-filter.txt"
+ "${GREP}" -v -E \
+ -f "${PATCH_DIR}/author-tags-filter.txt" \
+ "${PATCH_DIR}/author-tags-git.txt" \
+ > "${PATCH_DIR}/author-tags.txt"
fi
author_generic
diff --git a/precommit/src/main/shell/test-patch.d/whitespace.sh
b/precommit/src/main/shell/test-patch.d/whitespace.sh
index 492f723..df08a37 100755
--- a/precommit/src/main/shell/test-patch.d/whitespace.sh
+++ b/precommit/src/main/shell/test-patch.d/whitespace.sh
@@ -75,6 +75,7 @@ function whitespace_postcompile
declare result=0
declare -a eolignore
declare -a tabsignore
+ declare -a globalignore
declare temp1
declare temp2
@@ -89,7 +90,7 @@ function whitespace_postcompile
if [[ -n "${WHITESPACE_EOL_IGNORE_LIST}" ]]; then
eolignore=("${GREP}" "-v")
- yetus_comma_to_array temp1 "${WHITESPACE_EOL_IGNORE_LIST}"
+ yetus_comma_to_array temp1 "${WHITESPACE_EOL_IGNORE_LIST}" ""
for temp2 in "${temp1[@]}"; do
eolignore+=("-e" "^$temp2:")
done
@@ -107,21 +108,31 @@ function whitespace_postcompile
tabsignore=("cat")
fi
+ if [[ -n "${EXCLUDE_PATHS_FILE}" ]]; then
+ globalignore=("${GREP}" "-v" "-E" "-f" "${EXCLUDE_PATHS_FILE}")
+ else
+ globalignore=("cat")
+ fi
+
case "${BUILDMODE}" in
patch)
"${GREP}" -E '[[:blank:]]$' \
"${GITDIFFCONTENT}" \
+ | "${globalignore[@]}" \
| "${eolignore[@]}" > "${PATCH_DIR}/whitespace-eol.txt"
# shellcheck disable=SC2016,SC2086
"${AWK}" '/\t/ {print $0}' \
"${GITDIFFCONTENT}" \
+ | "${globalignore[@]}" \
| "${tabsignore[@]}" > "${PATCH_DIR}/whitespace-tabs.txt"
;;
full)
"${GIT}" grep -n -I --extended-regexp '[[:blank:]]$' \
+ | "${globalignore[@]}" \
| "${eolignore[@]}" > "${PATCH_DIR}/whitespace-eol.txt"
# shellcheck disable=SC2086
"${GIT}" grep -n -I $'\t' \
+ | "${globalignore[@]}" \
| "${tabsignore[@]}" > "${PATCH_DIR}/whitespace-tabs.txt"
;;
esac
diff --git a/precommit/src/main/shell/test-patch.sh
b/precommit/src/main/shell/test-patch.sh
index dc1b9fb..2d2d532 100755
--- a/precommit/src/main/shell/test-patch.sh
+++ b/precommit/src/main/shell/test-patch.sh
@@ -696,6 +696,7 @@ function yetus_usage
yetus_add_option "--debug" "If set, then output some extra stuff to stderr"
yetus_add_option "--dirty-workspace" "Allow the local git workspace to have
uncommitted changes"
yetus_add_option "--empty-patch" "Create a summary of the current source
tree"
+ yetus_add_option "--excludes=<file>" "File of regexs to keep project files
out of the set of changes passed to plugins."
yetus_add_option "--git-offline" "Do not fail if git cannot do certain
remote operations"
yetus_add_option "--git-shallow" "Repo does not know about other branches or
tags"
yetus_add_option "--java-home=<path>" "Set JAVA_HOME (In Docker mode, this
should be local to the image)"
@@ -831,6 +832,9 @@ function parse_args
--dirty-workspace)
DIRTY_WORKSPACE=true
;;
+ --excludes=*)
+ EXCLUDE_PATHS_FILE=$(yetus_abs "${i#*=}")
+ ;;
--instance=*)
INSTANCE=${i#*=}
;;
@@ -952,6 +956,15 @@ function parse_args
yetus_add_array_element EXEC_MODES Robot
fi
+ if [[ -n "${EXCLUDE_PATHS_FILE}" ]]; then
+ if [[ -f "${EXCLUDE_PATHS_FILE}" ]]; then
+ EXCLUDE_PATHS_FILE=$(yetus_abs "${EXCLUDE_PATHS_FILE}")
+ else
+ yetus_error "ERROR: Excluded paths file (${EXCLUDE_PATHS_FILE}}) does
not exist!"
+ cleanup_and_exit 1
+ fi
+ fi
+
if [[ -n $UNIT_TEST_FILTER_FILE ]]; then
if [[ -f $UNIT_TEST_FILTER_FILE ]]; then
UNIT_TEST_FILTER_FILE=$(yetus_abs "${UNIT_TEST_FILTER_FILE}")
@@ -1342,6 +1355,8 @@ function determine_needed_tests
big_console_header "Determining needed tests"
echo "(Depending upon input size and number of plug-ins, this may take a
while)"
+ exclude_paths_from_changed_files
+
for i in "${CHANGED_FILES[@]}"; do
yetus_debug "Determining needed tests for ${i}"
personality_file_tests "${i}"
@@ -1417,6 +1432,11 @@ function copytpbits
# Set to be relative to ${PATCH_DIR}/precommit
USER_PLUGIN_DIR="${PATCH_DIR}/precommit/user-plugins"
+ if [[ -n ${EXCLUDE_PATHS_FILE}
+ && -f ${EXCLUDE_PATHS_FILE} ]]; then
+ yetus_debug "copying '${EXCLUDE_PATHS_FILE}' over to
'${PATCH_DIR}/precommit/excluded.txt'"
+ cp -pr "${EXCLUDE_PATHS_FILE}" "${PATCH_DIR}/precommit/excluded.txt"
+ fi
if [[ -n ${PERSONALITY}
&& -f ${PERSONALITY} ]]; then
yetus_debug "copying '${PERSONALITY}' over to
'${PATCH_DIR}/precommit/personality/provided.sh'"