Repository: yetus Updated Branches: refs/heads/YETUS-83 367bb4604 -> 72645f469
YETUS-177. add yetus_abs to yetuslib (trial) Project: http://git-wip-us.apache.org/repos/asf/yetus/repo Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/d1ebe368 Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/d1ebe368 Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/d1ebe368 Branch: refs/heads/YETUS-83 Commit: d1ebe36842db17cfa1e1cd7a197e4ac3165226ed Parents: 367bb46 Author: Allen Wittenauer <[email protected]> Authored: Wed Nov 11 09:09:28 2015 -0800 Committer: Allen Wittenauer <[email protected]> Committed: Wed Nov 11 10:59:26 2015 -0800 ---------------------------------------------------------------------- precommit/core.d/00-yetuslib.sh | 33 +++++++++++++++++++++++++++++++++ precommit/test-patch.d/java.sh | 6 +++--- precommit/test-patch.sh | 6 +++--- 3 files changed, 39 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/yetus/blob/d1ebe368/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..69b7915 --- a/precommit/core.d/00-yetuslib.sh +++ b/precommit/core.d/00-yetuslib.sh @@ -93,3 +93,36 @@ 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 absdir +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/d1ebe368/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/d1ebe368/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"
