build: lock material unit tests job to specific commit (#31569)
No longer locks the Material unit tests job to a specific branch, but rather allows locking to a specific commit from a given branch. This allows us to use the "master" branch from the `components` repository. PR Close #31569
This commit is contained in:

committed by
Miško Hevery

parent
7e46a6d99d
commit
0cd4c019cf
@ -2,9 +2,30 @@
|
||||
|
||||
set -u -e -o pipefail
|
||||
|
||||
# Ensure that the temporary directory does not exist.
|
||||
rm -rf ${MATERIAL_REPO_TMP_DIR}
|
||||
# Clones the Angular Material repository if the repository has not been cloned before. If
|
||||
# the repository is already cloned, the script refreshes the repository by syncing with
|
||||
# upstream and resetting to the desired Material commit (see "MATERIAL_REPO_COMMIT" variable).
|
||||
|
||||
# Clone the Material repository into the given temporary directory.
|
||||
git clone --depth 1 --branch ${MATERIAL_REPO_TAG} ${MATERIAL_REPO_URL} \
|
||||
${MATERIAL_REPO_TMP_DIR}
|
||||
if [[ ! -d "${MATERIAL_REPO_TMP_DIR}" ]]; then
|
||||
# Clone the Material repository if not present through restored cache.
|
||||
git clone --branch ${MATERIAL_REPO_BRANCH} ${MATERIAL_REPO_URL} ${MATERIAL_REPO_TMP_DIR}
|
||||
|
||||
# Switch into the cloned repository.
|
||||
cd ${MATERIAL_REPO_TMP_DIR}
|
||||
|
||||
# Reset branch to the desired commit.
|
||||
git reset --hard ${MATERIAL_REPO_COMMIT}
|
||||
else
|
||||
# Switch into the cached repository.
|
||||
cd ${MATERIAL_REPO_TMP_DIR}
|
||||
|
||||
# Only refresh the repository if the current branch HEAD is not
|
||||
# matching the desired commit.
|
||||
if [[ "$(git rev-parse HEAD)" != "${MATERIAL_REPO_COMMIT}" ]]; then
|
||||
# Pull the latest changes of the specified branch.
|
||||
git fetch origin ${MATERIAL_REPO_BRANCH}
|
||||
|
||||
# Reset the current branch to the desired commit.
|
||||
git reset --hard ${MATERIAL_REPO_COMMIT}
|
||||
fi
|
||||
fi
|
||||
|
Reference in New Issue
Block a user