blob: 04744d26ecf0ba543582d6f288f07649519900bf [file] [log] [blame]
Zack Williamsbe542312022-06-23 21:51:32 -07001#!/usr/bin/env bash
2
Joey Armstrong518f3572024-02-11 07:56:25 -05003# SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors
Zack Williamsbe542312022-06-23 21:51:32 -07004# 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