Repository: yetus Updated Branches: refs/heads/master 5f446b1d2 -> ba7ac4412
YETUS-177. add yetus_abs to yetuslib Signed-off-by: Sean Busbey <[email protected]> Signed-off-by: Kengo Seki <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/yetus/repo Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/ba7ac441 Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/ba7ac441 Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/ba7ac441 Branch: refs/heads/master Commit: ba7ac4412992788b4cf41f5c3aa69dc690d5ff4f Parents: 5f446b1 Author: Allen Wittenauer <[email protected]> Authored: Wed Nov 11 09:09:28 2015 -0800 Committer: Allen Wittenauer <[email protected]> Committed: Thu Nov 12 08:04:35 2015 -0800 ---------------------------------------------------------------------- precommit/core.d/00-yetuslib.sh | 32 ++++++++++++++++++++++++++++++++ precommit/test-patch.d/java.sh | 6 +++--- precommit/test-patch.sh | 6 +++--- 3 files changed, 38 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/yetus/blob/ba7ac441/precommit/core.d/00-yetuslib.sh ---------------------------------------------------------------------- diff --git a/precommit/core.d/00-yetuslib.sh b/precommit/core.d/00-yetuslib.sh old mode 100644 new mode 100755 index 6ab6682..273be72 --- a/precommit/core.d/00-yetuslib.sh +++ b/precommit/core.d/00-yetuslib.sh @@ -93,3 +93,35 @@ function yetus_run_and_redirect # run the actual command "${@}" >> "${logfile}" 2>&1 } + +## @description Given a filename or dir, return the absolute version of it +## @audience public +## @stability stable +## @param directory +## @replaceable no +## @returns 0 success +## @returns 1 failure +## @returns stdout abspath +function yetus_abs +{ + declare obj=$1 + declare dir + declare fn + + if [[ ! -e ${obj} ]]; then + return 1 + elif [[ -d ${obj} ]]; then + dir=${obj} + else + dir=$(dirname -- "${obj}") + fn=$(basename -- "${obj}") + fn="/${fn}" + fi + + dir=$(cd -P -- "${dir}" >/dev/null 2>/dev/null && pwd -P) + if [[ $? = 0 ]]; then + echo "${dir}${fn}" + return 0 + fi + return 1 +} http://git-wip-us.apache.org/repos/asf/yetus/blob/ba7ac441/precommit/test-patch.d/java.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/java.sh b/precommit/test-patch.d/java.sh index ff66150..3254371 100755 --- a/precommit/test-patch.d/java.sh +++ b/precommit/test-patch.d/java.sh @@ -58,11 +58,11 @@ function initialize_java esac fi - JAVA_HOME=$(cd -P -- "${JAVA_HOME}" >/dev/null && pwd -P) + JAVA_HOME=$(yetus_abs "${JAVA_HOME}") for i in ${JDK_DIR_LIST}; do if [[ -d "${i}" ]]; then - jdkdir=$(cd -P -- "${i}" >/dev/null && pwd -P) + jdkdir=$(yetus_abs "${i}") if [[ ${jdkdir} != "${JAVA_HOME}" ]]; then tmplist="${tmplist} ${jdkdir}" fi @@ -209,4 +209,4 @@ function javadoc_logfilter #shellcheck disable=SC2016,SC2046 ${GREP} "^.*.java:[0-9]*:" "${input}" > "${output}" -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/yetus/blob/ba7ac441/precommit/test-patch.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh index 72ca097..1847848 100755 --- a/precommit/test-patch.sh +++ b/precommit/test-patch.sh @@ -871,7 +871,7 @@ function parse_args # we need absolute dir for ${BASEDIR} cd "${STARTINGDIR}" - BASEDIR=$(cd -P -- "${BASEDIR}" >/dev/null && pwd -P) + BASEDIR=$(yetus_abs "${BASEDIR}") if [[ -n ${USER_PATCH_DIR} ]]; then PATCH_DIR="${USER_PATCH_DIR}" @@ -889,7 +889,7 @@ function parse_args fi # we need absolute dir for PATCH_DIR - PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P) + PATCH_DIR=$(yetus_abs "${PATCH_DIR}") if [[ ${JENKINS} == "true" ]]; then echo "Running in Jenkins mode" @@ -905,7 +905,7 @@ function parse_args fi if [[ -n "${USER_PLUGIN_DIR}" ]]; then - USER_PLUGIN_DIR=$(cd -P -- "${USER_PLUGIN_DIR}" >/dev/null && pwd -P) + USER_PLUGIN_DIR=$(yetus_abs "${USER_PLUGIN_DIR}") fi GITDIFFLINES="${PATCH_DIR}/gitdifflines.txt"
