From f07075d0dd9f340050f93c40d94220457ca44e44 Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Mon, 12 Jan 2026 05:42:12 -0800 Subject: [PATCH] Variable renaming --- git-clone-related | 7 +++--- .../test-git-clone-related.sh | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/git-clone-related b/git-clone-related index 7c06bbb..1cef876 100755 --- a/git-clone-related +++ b/git-clone-related @@ -57,7 +57,7 @@ if [ "$1" = "--upstream-branch" ]; then fi if [ "$#" -lt 2 ]; then - echo "Usage: $0 UPSTREAM_ORG REPO [DESTINATION] [GIT_CLONE_ARGS...]" >&2 + echo "Usage: $0 UPSTREAM_ORG REPO_NAME [DESTINATION] [GIT_CLONE_ARGS...]" >&2 exit 1 fi @@ -155,7 +155,7 @@ else REPO_BRANCH=$("${SCRIPT_DIR}"/git-find-branch "${REPO_URL}" "${CI_BRANCH_NAME}" ${FALLBACK_BRANCH:+"$FALLBACK_BRANCH"}) fi echo "About to run: git clone -q -b ${REPO_BRANCH} $* ${REPO_URL} ${DESTINATION}" - # Try twice in case of network lossage. 60 seconds is not enough for a branch of the JDK. + # Try twice in case of network lossage. 60 seconds is not enough to clone a branch of the JDK. timeout 180 git clone -q -b "${REPO_BRANCH}" "$@" "${REPO_URL}" "${DESTINATION}" \ || { echo "Retrying 'git clone ... ${REPO_URL} ${DESTINATION}' after timeout" \ && rm -rf "${DESTINATION}" \ @@ -166,4 +166,5 @@ else exit 2 }; }; } fi -echo "git-clone-related: ${DESTINATION} is at $(cd "${DESTINATION}" && git rev-parse HEAD)" + +echo "$0: ${DESTINATION} is at $(cd "${DESTINATION}" && git rev-parse HEAD)" diff --git a/tests/git-clone-related-test/test-git-clone-related.sh b/tests/git-clone-related-test/test-git-clone-related.sh index a80558b..c0c9d4d 100755 --- a/tests/git-clone-related-test/test-git-clone-related.sh +++ b/tests/git-clone-related-test/test-git-clone-related.sh @@ -24,8 +24,8 @@ set -o errexit -o nounset USER=${USER:-git-clone-related} PLUME_SCRIPTS=$(cd ../../ && pwd -P) startdir=$(mktemp -d 2> /dev/null || mktemp -d -t 'startdir') -goaldir=$(mktemp -d 2> /dev/null || mktemp -d -t 'goaldir') -rm -rf "$startdir" "$goaldir" +resultdir=$(mktemp -d 2> /dev/null || mktemp -d -t 'resultdir') +rm -rf "$startdir" "$resultdir" git clone --branch "$START_BRANCH" "$START_REPO" "$startdir" -q --single-branch --depth 1 # This test might itself be running under CI, so unset the variables that @@ -35,21 +35,23 @@ unset BUILD_SOURCEBRANCH unset TRAVIS unset CIRCLE_COMPARE_URL unset GITHUB_HEAD_REF + # shellcheck disable=SC2086 # $ARGS should not be quoted -(cd "$startdir" && "${PLUME_SCRIPTS}"/git-clone-related $ARGS "$goaldir") -clonedrepo=$(git -C "$goaldir" config --get remote.origin.url) +(cd "$startdir" && "${PLUME_SCRIPTS}"/git-clone-related $ARGS "$resultdir") + +clonedrepo=$(git -C "$resultdir" config --get remote.origin.url) # git 2.22 and later has `git branch --show-current`; CircleCI doesn't have that version yet. -clonedbranch=$(git -C "$goaldir" rev-parse --abbrev-ref HEAD) +clonedbranch=$(git -C "$resultdir" rev-parse --abbrev-ref HEAD) -rm -rf "$startdir" "$goaldir" +rm -rf "$startdir" "$resultdir" if [ "$clonedrepo" != "$GOAL_REPO" ]; then - echo "test-git-clone-related.sh \"$1\" \"$2\" \"$3\" \"$4\" \"$5\"" - echo "expected repo $GOAL_REPO, got: $clonedrepo" + echo "error: test-git-clone-related.sh \"$1\" \"$2\" \"$3\" \"$4\" \"$5\"" + echo "error: expected repo $GOAL_REPO, got: $clonedrepo" exit 2 fi if [ "$clonedbranch" != "$GOAL_BRANCH" ]; then - echo "test-git-clone-related.sh \"$1\" \"$2\" \"$3\" \"$4\" \"$5\"" - echo "expected branch $GOAL_BRANCH, got: $clonedbranch" + echo "error: test-git-clone-related.sh \"$1\" \"$2\" \"$3\" \"$4\" \"$5\"" + echo "error: expected branch $GOAL_BRANCH, got: $clonedbranch" exit 2 fi