You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by aw...@apache.org on 2019/01/03 01:50:12 UTC
[yetus] branch master updated (ae6d2fb -> 28ef852)
This is an automated email from the ASF dual-hosted git repository.
aw pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/yetus.git.
from ae6d2fb YETUS-738. Some Jenkinsfile improvements
new 721f544 YETUS-750. don't try patch on a git format-patch file
new bd85e17 YETUS-37. make test-patch ruby-lint plugin configurable
new 28ef852 YETUS-36. make test-patch rubocop plugin configurable
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
precommit/src/main/shell/core.d/01-common.sh | 6 ---
precommit/src/main/shell/core.d/patchfiles.sh | 37 ++++++++++++++-
precommit/src/main/shell/smart-apply-patch.sh | 2 +-
precommit/src/main/shell/test-patch.d/rubocop.sh | 52 ++++++++++++++--------
precommit/src/main/shell/test-patch.d/ruby-lint.sh | 48 +++++++++++++-------
5 files changed, 100 insertions(+), 45 deletions(-)
[yetus] 02/03: YETUS-37. make test-patch ruby-lint plugin
configurable
Posted by aw...@apache.org.
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
commit bd85e1726641067dc7f177751a7f42e300370d47
Author: Allen Wittenauer <aw...@apache.org>
AuthorDate: Fri Dec 28 18:51:43 2018 -0800
YETUS-37. make test-patch ruby-lint plugin configurable
Signed-off-by: Allen Wittenauer <aw...@apache.org>
---
precommit/src/main/shell/test-patch.d/ruby-lint.sh | 48 ++++++++++++++--------
1 file changed, 31 insertions(+), 17 deletions(-)
diff --git a/precommit/src/main/shell/test-patch.d/ruby-lint.sh b/precommit/src/main/shell/test-patch.d/ruby-lint.sh
index 50c2d7b..a04dc76 100755
--- a/precommit/src/main/shell/test-patch.d/ruby-lint.sh
+++ b/precommit/src/main/shell/test-patch.d/ruby-lint.sh
@@ -25,6 +25,8 @@ RUBY_LINT=${RUBY_LINT:-$(command -v ruby-lint 2>/dev/null)}
function ruby_lint_usage
{
yetus_add_option "--ruby-lint=<path>" "path to ruby-lint executable"
+ yetus_add_option "--ruby-lint-config=<path>" "path to ruby-lint config, relative to source tree [default: none]"
+
}
function ruby_lint_parse_args
@@ -36,6 +38,9 @@ function ruby_lint_parse_args
--ruby-lint=*)
RUBY_LINT=${i#*=}
;;
+ --ruby-lint-config=*)
+ RUBY_LINT_CONFIG=${i#*=}
+ ;;
esac
done
}
@@ -57,6 +62,29 @@ function ruby_lint_precheck
fi
}
+function ruby_lint_exec
+{
+ declare i
+ declare repostatus=$1
+ declare args
+
+ args=('-p' 'syntastic')
+
+ echo "Running ruby-lint against identified ruby scripts."
+ pushd "${BASEDIR}" >/dev/null || return 1
+ if [[ -f "${RUBY_LINT_CONFIG}" ]]; then
+ args+=('-c' "${RUBY_LINT_CONFIG}")
+ fi
+
+ for i in "${CHANGED_FILES[@]}"; do
+ if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
+ "${RUBY_LINT}" -p "${args[@]}" "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/branch-ruby-lint-result.txt"
+ fi
+ done
+ popd >/dev/null || return 1
+ return 0
+}
+
function ruby_lint_preapply
{
local i
@@ -69,14 +97,8 @@ function ruby_lint_preapply
start_clock
- echo "Running ruby-lint against identified ruby scripts."
- pushd "${BASEDIR}" >/dev/null || return 1
- for i in "${CHANGED_FILES[@]}"; do
- if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- "${RUBY_LINT}" -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/branch-ruby-lint-result.txt"
- fi
- done
- popd >/dev/null || return 1
+ ruby_lint_exec branch
+
# keep track of how much as elapsed for us already
RUBY_LINT_TIMER=$(stop_clock)
return 0
@@ -143,15 +165,7 @@ function ruby_lint_postapply
# by setting the clock back
offset_clock "${RUBY_LINT_TIMER}"
- echo "Running ruby-lint against identified ruby scripts."
- # we re-check this in case one has been added
- pushd "${BASEDIR}" >/dev/null || return 1
- for i in "${CHANGED_FILES[@]}"; do
- if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- "${RUBY_LINT}" -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/patch-ruby-lint-result.txt"
- fi
- done
- popd >/dev/null || return 1
+ ruby_lint_exec patch
# shellcheck disable=SC2016
RUBY_LINT_VERSION=$("${RUBY_LINT}" -v | "${AWK}" '{print $2}')
[yetus] 01/03: YETUS-750. don't try patch on a git format-patch file
Posted by aw...@apache.org.
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
commit 721f544a4763aebfc73aaec70740e8ad9e95889b
Author: Allen Wittenauer <aw...@apache.org>
AuthorDate: Sun Dec 30 16:07:05 2018 -0800
YETUS-750. don't try patch on a git format-patch file
Signed-off-by: Allen Wittenauer <aw...@apache.org>
---
precommit/src/main/shell/core.d/01-common.sh | 6 -----
precommit/src/main/shell/core.d/patchfiles.sh | 37 +++++++++++++++++++++++++--
precommit/src/main/shell/smart-apply-patch.sh | 2 +-
3 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/precommit/src/main/shell/core.d/01-common.sh b/precommit/src/main/shell/core.d/01-common.sh
index e292336..db87e97 100755
--- a/precommit/src/main/shell/core.d/01-common.sh
+++ b/precommit/src/main/shell/core.d/01-common.sh
@@ -49,12 +49,6 @@ function common_defaults
PATCH_DIR=/tmp/yetus-${RANDOM}.${RANDOM}
done
#shellcheck disable=SC2034
- PATCH_METHOD=""
- #shellcheck disable=SC2034
- PATCH_METHODS=("gitapply" "patchcmd")
- #shellcheck disable=SC2034
- PATCH_LEVEL=0
- #shellcheck disable=SC2034
PATCH_SYSTEM=""
PROJECT_NAME=unknown
# seed $RANDOM
diff --git a/precommit/src/main/shell/core.d/patchfiles.sh b/precommit/src/main/shell/core.d/patchfiles.sh
index 381573c..e0db5fc 100755
--- a/precommit/src/main/shell/core.d/patchfiles.sh
+++ b/precommit/src/main/shell/core.d/patchfiles.sh
@@ -14,6 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+PATCH_METHOD=""
+PATCH_METHODS=("gitapply" "patchcmd")
+PATCH_LEVEL=0
+PATCH_HINT=""
+
## @description Use curl to download the patch as a last resort
## @audience private
## @stability evolving
@@ -73,6 +78,28 @@ function guess_patch_file
patchfile_dryrun_driver "${patch}"
}
+## @description Provide a hint on what tool should be used to process a patch file
+## @description Sets PATCH_HINT to provide the hint. Will not do anything if
+## @description PATCH_HINT or PATCH_METHOD is already set
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param path to patch file to test
+function patch_file_hinter
+{
+ declare patch=$1
+
+ if [[ -z "${PATCH_HINT}" ]] && [[ -z "${PATCH_METHOD}" ]]; then
+ if head -n 1 "${patch}" | "${GREP}" -q -E "^From [a-z0-9]* Mon Sep 17 00:00:00 2001" &&
+ "${GREP}" -q "^From: " "${patch}" &&
+ "${GREP}" -q "^Subject: \[PATCH" "${patch}" &&
+ "${GREP}" -q "^---" "${patch}"; then
+ PATCH_HINT="git"
+ return
+ fi
+ fi
+}
+
## @description Given ${PATCH_OR_ISSUE}, determine what type of patch file is in use,
## @description and do the necessary work to place it into ${PATCH_DIR}/patch.
## @audience private
@@ -204,7 +231,7 @@ function gitapply_dryrun
declare patchfile=$1
declare prefixsize=${2:-0}
- while [[ ${prefixsize} -lt 4
+ while [[ ${prefixsize} -lt 2
&& -z ${PATCH_METHOD} ]]; do
if yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
"${GIT}" apply --binary -v --check "-p${prefixsize}" "${patchfile}"; then
@@ -234,7 +261,7 @@ function patchcmd_dryrun
declare patchfile=$1
declare prefixsize=${2:-0}
- while [[ ${prefixsize} -lt 4
+ while [[ ${prefixsize} -lt 2
&& -z ${PATCH_METHOD} ]]; do
# shellcheck disable=SC2153
if yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
@@ -265,8 +292,14 @@ function patchfile_dryrun_driver
declare patchfile=$1
declare method
+ patch_file_hinter "${patchfile}"
+
#shellcheck disable=SC2153
for method in "${PATCH_METHODS[@]}"; do
+ if [[ -n "${PATCH_HINT}" ]] &&
+ [[ ! "${method}" =~ ${PATCH_HINT} ]]; then
+ continue
+ fi
if declare -f "${method}_dryrun" >/dev/null; then
"${method}_dryrun" "${patchfile}"
fi
diff --git a/precommit/src/main/shell/smart-apply-patch.sh b/precommit/src/main/shell/smart-apply-patch.sh
index bf44a8f..bdee4cb 100755
--- a/precommit/src/main/shell/smart-apply-patch.sh
+++ b/precommit/src/main/shell/smart-apply-patch.sh
@@ -324,7 +324,7 @@ if [[ ${COMMITMODE} = true ]]; then
fi
PATCH_METHODS=("gitam" "${PATCH_METHODS[@]}")
fi
-
+patch_file_hinter "${PATCH_DIR}/patch"
patchfile_dryrun_driver "${PATCH_DIR}/patch"
RESULT=$?
[yetus] 03/03: YETUS-36. make test-patch rubocop plugin configurable
Posted by aw...@apache.org.
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
commit 28ef852e2685e845ae20528e2ec872f2599e8e76
Author: Allen Wittenauer <aw...@apache.org>
AuthorDate: Fri Dec 28 18:43:45 2018 -0800
YETUS-36. make test-patch rubocop plugin configurable
Signed-off-by: Allen Wittenauer <aw...@apache.org>
---
precommit/src/main/shell/test-patch.d/rubocop.sh | 52 +++++++++++++++---------
1 file changed, 33 insertions(+), 19 deletions(-)
diff --git a/precommit/src/main/shell/test-patch.d/rubocop.sh b/precommit/src/main/shell/test-patch.d/rubocop.sh
index 490c985..dd1a322 100755
--- a/precommit/src/main/shell/test-patch.d/rubocop.sh
+++ b/precommit/src/main/shell/test-patch.d/rubocop.sh
@@ -25,6 +25,7 @@ RUBOCOP=${RUBOCOP:-$(command -v rubocop 2>/dev/null)}
function rubocop_usage
{
yetus_add_option "--rubocop=<path>" "path to rubocop executable"
+ yetus_add_option "--rubocopy-config=<path>" "relative path to rubocop config in source tree [default: none]"
}
function rubocop_parse_args
@@ -36,6 +37,9 @@ function rubocop_parse_args
--rubocop=*)
RUBOCOP=${i#*=}
;;
+ --rubocop-config=*)
+ RUBOCOP_CONFIG=${i#*=}
+ ;;
esac
done
}
@@ -58,9 +62,34 @@ function rubocop_precheck
}
+function rubocop_exec
+{
+ declare i
+ declare repostatus=$1
+ declare -a args
+
+ args=('-f' 'e')
+
+ echo "Running rubocop against identified ruby scripts."
+ pushd "${BASEDIR}" >/dev/null || return 1
+
+ if [[ -f "${RUBOCOP_CONFIG}" ]]; then
+ args+=('-c' "${RUBOCOP_CONFIG}")
+ fi
+
+ for i in "${CHANGED_FILES[@]}"; do
+ if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
+ "${RUBOCOP}" "${args[@]}" "${i}" | "${AWK}" '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/${repostatus}-rubocop-result.txt"
+ fi
+ done
+ popd >/dev/null || return 1
+ return 0
+}
+
function rubocop_preapply
{
- local i
+ declare i
+ declare -a args
if ! verify_needed_test rubocop; then
return 0
@@ -70,15 +99,8 @@ function rubocop_preapply
start_clock
- echo "Running rubocop against identified ruby scripts."
- pushd "${BASEDIR}" >/dev/null || return 1
- for i in "${CHANGED_FILES[@]}"; do
- if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- "${RUBOCOP}" -f e "${i}" | "${AWK}" '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/branch-rubocop-result.txt"
- fi
- done
- popd >/dev/null || return 1
- # keep track of how much as elapsed for us already
+ rubocop_exec branch
+
RUBOCOP_TIMER=$(stop_clock)
return 0
}
@@ -116,15 +138,7 @@ function rubocop_postapply
# by setting the clock back
offset_clock "${RUBOCOP_TIMER}"
- echo "Running rubocop against identified ruby scripts."
- # we re-check this in case one has been added
- pushd "${BASEDIR}" >/dev/null || return 1
- for i in "${CHANGED_FILES[@]}"; do
- if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- "${RUBOCOP}" -f e "${i}" | "${AWK}" '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/patch-rubocop-result.txt"
- fi
- done
- popd >/dev/null || return 1
+ rubocop_exec patch
# shellcheck disable=SC2016
RUBOCOP_VERSION=$("${RUBOCOP}" -v | "${AWK}" '{print $NF}')