X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fgerrit-fetch-dependencies.sh;h=1cb5177460979018a3c9f8606839ee81db4dcc8a;hb=0b1d0ba4945b93dc5d86fffef20f4be44fc5a2f9;hp=4870b10e7b3ef01ba3f72253b1a43964cac31f62;hpb=08c998aade122668eb8726f826d697813e23abea;p=releng%2Fglobal-jjb.git diff --git a/shell/gerrit-fetch-dependencies.sh b/shell/gerrit-fetch-dependencies.sh index 4870b10e..1cb51774 100644 --- a/shell/gerrit-fetch-dependencies.sh +++ b/shell/gerrit-fetch-dependencies.sh @@ -22,7 +22,18 @@ set -eu -o pipefail REPOS_DIR="$WORKSPACE/.repos" -PATCHES=($(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'recheck:' | awk -F: '{print $2}')) +IFS=" " read -r -a PATCHES <<< "$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'recheck:' | awk -F: '{print $2}')" + +# Workaround for git-review bug in v1.24 +# https://storyboard.openstack.org/#!/story/2001081 +set +u # Allow unbound variables for virtualenv +virtualenv --quiet "/tmp/v/git-review" +# shellcheck source=/tmp/v/git-review/bin/activate disable=SC1091 +source "/tmp/v/git-review/bin/activate" +pip install --quiet --upgrade "pip==9.0.3" setuptools +pip install --quiet --upgrade git-review +set -u +# End git-review workaround projects=() for patch in $(echo "${PATCHES[@]}"); do @@ -30,6 +41,11 @@ for patch in $(echo "${PATCHES[@]}"); do project=$(echo "$json" | jq -r '.project') branch=$(echo "$json" | jq -r '.branch') + if [ "$GERRIT_CHANGE_NUMBER" == "$patch" ]; then + echo "WARN: GERRIT_CHANGE and $patch are one and the same. Ignoring patch..." + continue + fi + if [ ! -d "$REPOS_DIR/$project" ]; then git clone -q --depth 1 -b "$branch" "$GIT_URL/$project" "$REPOS_DIR/$project" @@ -38,7 +54,10 @@ for patch in $(echo "${PATCHES[@]}"); do fi pushd "$REPOS_DIR/$project" - git remote add gerrit "$GIT_URL/$project" + # If remote gerrit already exists just make sure path is expected + if ! git remote add gerrit "$GERRIT_URL/$project" > /dev/null 2>&1; then + git remote set-url gerrit "$GERRIT_URL/$project" + fi git review --cherrypick="$patch" popd done