1
0
Fork 0
This commit is contained in:
Mikhail Goncharov 2023-08-28 17:32:20 +00:00
parent ef4117f870
commit 12e76518e2
2 changed files with 27 additions and 1 deletions

View file

@ -1,2 +1,2 @@
REM TODO: use powershell shell for hooks directly
powershell c:\scripts\pre-checkout.ps1
bash c:\scripts\pre-checkout.sh

View file

@ -0,0 +1,26 @@
#/usr/bin/env bash
echo "BUILDKITE_BUILD_CHECKOUT_PATH: $BUILDKITE_BUILD_CHECKOUT_PATH"
echo "BUILDKITE_BUILD_PATH: $BUILDKITE_BUILD_PATH"
echo "unlocking git"
pkill -f git.exe
rm -f "$BUILDKITE_BUILD_CHECKOUT_PATH/.git/index.lock"
echo 'running processes (before)'
ps aux | grep "$BUILDKITE_BUILD_CHECKOUT_PATH"
echo "unlocking $BUILDKITE_BUILD_CHECKOUT_PATH"
handle -nobanner "$BUILDKITE_BUILD_CHECKOUT_PATH"
powershell /c/scripts/unlock_path.ps1 "$BUILDKITE_BUILD_CHECKOUT_PATH"
echo 'running processes (after)'
ps aux | grep "$BUILDKITE_BUILD_CHECKOUT_PATH"
echo "BUILDKITE_REPO: $BUILDKITE_REPO"
if [ -d "$BUILDKITE_BUILD_CHECKOUT_PATH" ]; then
cd "$BUILDKITE_BUILD_CHECKOUT_PATH" || exit
remoteUrl=$(git remote get-url origin)
echo "current remote URL: $remoteUrl"
if [ "$remoteUrl" != "$BUILDKITE_REPO" ]; then
echo "Remote URL does not match. Deleting and recreating the directory."
cd /c/
rm -rf "$BUILDKITE_BUILD_CHECKOUT_PATH"
fi
fi