test/diff-manifests: checkout repo to $head on exit
During the diff-manifests.sh test the source repository checkout is changed to generate manifests from current main branch for comparion. We want to checkout back to $head after the script is done or in case of any unexpected exit.
This commit is contained in:
parent
cf562dbb57
commit
74bf3aa3df
1 changed files with 5 additions and 0 deletions
|
|
@ -9,6 +9,9 @@ function greenprint {
|
||||||
function redprint {
|
function redprint {
|
||||||
echo -e "\033[1;31m[$(date -Isecond)] ${1}\033[0m"
|
echo -e "\033[1;31m[$(date -Isecond)] ${1}\033[0m"
|
||||||
}
|
}
|
||||||
|
function revert_to_head {
|
||||||
|
git checkout "$head"
|
||||||
|
}
|
||||||
|
|
||||||
if [[ "${CI_COMMIT_BRANCH}" != PR-* ]]; then
|
if [[ "${CI_COMMIT_BRANCH}" != PR-* ]]; then
|
||||||
greenprint "${CI_COMMIT_BRANCH} is not a Pull Request"
|
greenprint "${CI_COMMIT_BRANCH} is not a Pull Request"
|
||||||
|
|
@ -60,6 +63,8 @@ if (( err != 0 )); then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# revert to $head on exit
|
||||||
|
trap revert_to_head EXIT
|
||||||
greenprint "Checking out merge-base ${mergebase}"
|
greenprint "Checking out merge-base ${mergebase}"
|
||||||
git checkout "${mergebase}"
|
git checkout "${mergebase}"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue