windows pre-commit hooks
This commit is contained in:
parent
80978127ee
commit
948643df52
3 changed files with 32 additions and 6 deletions
|
@ -114,7 +114,8 @@ RUN git config --system core.longpaths true & `
|
||||||
git config --global core.autocrlf false
|
git config --global core.autocrlf false
|
||||||
|
|
||||||
RUN choco install -y handle
|
RUN choco install -y handle
|
||||||
COPY start_agent.ps1 C:\scripts\
|
COPY start_agent.ps1 c:\scripts\
|
||||||
|
COPY pre-checkout.ps1 c:\scripts\
|
||||||
COPY pre-checkout.bat c:\buildkite-agent\hooks\
|
COPY pre-checkout.bat c:\buildkite-agent\hooks\
|
||||||
COPY post-checkout.bat c:\buildkite-agent\hooks\
|
COPY post-checkout.bat c:\buildkite-agent\hooks\
|
||||||
CMD "powershell C:\scripts\start_agent.ps1"
|
CMD "powershell C:\scripts\start_agent.ps1"
|
||||||
|
|
|
@ -1,5 +1,2 @@
|
||||||
echo "pre-checkout: update scripts"
|
REM TODO: use powershell shell for hooks directly
|
||||||
cd c:\llvm-premerge-checks
|
powershell c:\scripts\pre-checkout.ps1
|
||||||
git pull
|
|
||||||
git rev-parse HEAD
|
|
||||||
powershell c:\llvm-premerge-checks\scripts\windows\pre-checkout.ps1
|
|
28
containers/agent-windows-buildkite/pre-checkout.ps1
Normal file
28
containers/agent-windows-buildkite/pre-checkout.ps1
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
$srcDirectory = "c:\src"
|
||||||
|
$env:BUILDKITE_BUILD_CHECKOUT_PATH=$srcDirectory
|
||||||
|
|
||||||
|
echo "unlocking git"
|
||||||
|
taskkill /F /IM git.exe
|
||||||
|
rm -Force "$env:BUILDKITE_BUILD_CHECKOUT_PATH/.git/index.lock"
|
||||||
|
echo "BUILDKITE_BUILD_CHECKOUT_PATH: $env:BUILDKITE_BUILD_CHECKOUT_PATH"
|
||||||
|
echo "BUILDKITE_BUILD_PATH: $env:BUILDKITE_BUILD_PATH"
|
||||||
|
echo 'running processes (before)'
|
||||||
|
Get-Process | Where-Object {$_.Path -like "$env:BUILDKITE_BUILD_PATH*"} | Select-Object -ExpandProperty Path
|
||||||
|
echo "unlocking $env:BUILDKITE_BUILD_PATH"
|
||||||
|
handle -nobanner $env:BUILDKITE_BUILD_CHECKOUT_PATH
|
||||||
|
c:\llvm-premerge-checks\scripts\windows\unlock_path.ps1 $env:BUILDKITE_BUILD_CHECKOUT_PATH
|
||||||
|
echo 'running processes (after)'
|
||||||
|
Get-Process | Where-Object {$_.Path -like "$env:BUILDKITE_BUILD_PATH*"} | Select-Object -ExpandProperty Path
|
||||||
|
|
||||||
|
echo "BUILDKITE_REPO: $env:BUILDKITE_REPO"
|
||||||
|
if (Test-Path -Path $env:BUILDKITE_BUILD_CHECKOUT_PATH) {
|
||||||
|
Set-Location -Path $env:BUILDKITE_BUILD_CHECKOUT_PATH
|
||||||
|
$remoteUrl = git remote get-url origin
|
||||||
|
echo "current remote URL: $remoteUrl"
|
||||||
|
if ($remoteUrl -ne $env:BUILDKITE_REPO) {
|
||||||
|
Write-Host "Remote URL does not match. Deleting and recreating the directory."
|
||||||
|
Set-Location -Path "C:\"
|
||||||
|
Remove-Item -Path $env:BUILDKITE_BUILD_CHECKOUT_PATH -Recurse -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue