blob: 4176df033dfba5463be74e278a4b2a91736a268d [file] [log] [blame]
Zack Williamsbe542312022-06-23 21:51:32 -07001#!/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
9set -eu -o pipefail
10
11# verify that we have repo installed
12command -v repo >/dev/null 2>&1 || { echo "repo not found, please install it" >&2; exit 1; }
13
14echo "BASEDIR: ${BASEDIR}"
15echo "GERRIT_PROJECT: ${GERRIT_PROJECT}"
16echo "GERRIT_CHANGE_NUMBER: ${GERRIT_CHANGE_NUMBER}"
17echo "GERRIT_PATCHSET_NUMBER: ${GERRIT_PATCHSET_NUMBER}"
18
19pushd "${BASEDIR}"
20echo "Checking out a patchset with repo, using repo version:"
21repo version
22
23PROJECT_PATH=$(xmllint --xpath "string(//project[@name=\"${GERRIT_PROJECT}\"]/@path)" .repo/manifests/default.xml)
24
25if [ -z "$PROJECT_PATH" ]
26then
27 echo "WARNING: Project not in repo! Not downloading the changeset."
28else
29 echo "Project Path: $PROJECT_PATH"
30 repo download "${PROJECT_PATH}" "$GERRIT_CHANGE_NUMBER/${GERRIT_PATCHSET_NUMBER}"
31fi
32
33popd