mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 11:05:46 +00:00
scripts: Add a bash function to sync external code
Added a bash function in integration test script to checkout source code of a GIT repo with specified branch and commit. Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
parent
6037c83585
commit
b7cb6257b5
@ -12,6 +12,46 @@ EDK2_BUILD_DIR="$WORKLOADS_DIR/edk2_build"
|
|||||||
|
|
||||||
mkdir -p "$WORKLOADS_DIR"
|
mkdir -p "$WORKLOADS_DIR"
|
||||||
|
|
||||||
|
# Checkout source code of a GIT repo with specified branch and commit
|
||||||
|
# Args:
|
||||||
|
# $1: Target directory
|
||||||
|
# $2: GIT URL of the repo
|
||||||
|
# $3: Required branch
|
||||||
|
# $4: Required commit (optional)
|
||||||
|
checkout_repo() {
|
||||||
|
SRC_DIR="$1"
|
||||||
|
GIT_URL="$2"
|
||||||
|
GIT_BRANCH="$3"
|
||||||
|
GIT_COMMIT="$4"
|
||||||
|
|
||||||
|
# Check whether the local HEAD commit same as the requested commit or not.
|
||||||
|
# If commit is not specified, compare local HEAD and remote HEAD.
|
||||||
|
# Remove the folder if there is difference.
|
||||||
|
if [ -d "$SRC_DIR" ]; then
|
||||||
|
pushd $SRC_DIR
|
||||||
|
git fetch
|
||||||
|
SRC_LOCAL_COMMIT=$(git rev-parse HEAD)
|
||||||
|
if [ -z "$GIT_COMMIT" ]; then
|
||||||
|
GIT_COMMIT=$(git rev-parse remotes/origin/"$GIT_BRANCH")
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
if [ "$SRC_LOCAL_COMMIT" != "$GIT_COMMIT" ]; then
|
||||||
|
rm -rf "$SRC_DIR"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checkout the specified branch and commit (if required)
|
||||||
|
if [ ! -d "$SRC_DIR" ]; then
|
||||||
|
git clone --depth 1 "$GIT_URL" -b "$GIT_BRANCH" "$SRC_DIR"
|
||||||
|
if [ "$GIT_COMMIT" ]; then
|
||||||
|
pushd "$SRC_DIR"
|
||||||
|
git fetch --depth 1 origin "$GIT_COMMIT"
|
||||||
|
git reset --hard FETCH_HEAD
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
build_edk2() {
|
build_edk2() {
|
||||||
EDK2_REPO="https://github.com/tianocore/edk2.git"
|
EDK2_REPO="https://github.com/tianocore/edk2.git"
|
||||||
EDK2_DIR="edk2"
|
EDK2_DIR="edk2"
|
||||||
|
Loading…
Reference in New Issue
Block a user