Zack Williams | be54231 | 2022-06-23 21:51:32 -0700 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # SPDX-FileCopyrightText: 2018-2022 Open Networking Foundation |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | # repo-patch.sh |
| 7 | # downloads a patch to within an already checked out repo tree |
| 8 | |
| 9 | set -eu -o pipefail |
| 10 | |
| 11 | # verify that we have repo installed |
| 12 | command -v repo >/dev/null 2>&1 || { echo "repo not found, please install it" >&2; exit 1; } |
| 13 | |
| 14 | echo "BASEDIR: ${BASEDIR}" |
| 15 | echo "GERRIT_PROJECT: ${GERRIT_PROJECT}" |
| 16 | echo "GERRIT_CHANGE_NUMBER: ${GERRIT_CHANGE_NUMBER}" |
| 17 | echo "GERRIT_PATCHSET_NUMBER: ${GERRIT_PATCHSET_NUMBER}" |
| 18 | |
| 19 | pushd "${BASEDIR}" |
| 20 | echo "Checking out a patchset with repo, using repo version:" |
| 21 | repo version |
| 22 | |
| 23 | PROJECT_PATH=$(xmllint --xpath "string(//project[@name=\"${GERRIT_PROJECT}\"]/@path)" .repo/manifests/default.xml) |
| 24 | |
| 25 | if [ -z "$PROJECT_PATH" ] |
| 26 | then |
| 27 | echo "WARNING: Project not in repo! Not downloading the changeset." |
| 28 | else |
| 29 | echo "Project Path: $PROJECT_PATH" |
| 30 | repo download "${PROJECT_PATH}" "$GERRIT_CHANGE_NUMBER/${GERRIT_PATCHSET_NUMBER}" |
| 31 | fi |
| 32 | |
| 33 | popd |