git-docker/windows/clone-commit.ps1

18 lines
584 B
PowerShell
Raw Normal View History

2018-09-11 18:06:54 +00:00
Set-Variable -Name "FLAGS" -Value ""
if ($Env:PLUGIN_DEPTH) {
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
}
if (!(Test-Path .git)) {
2018-12-14 01:52:14 +00:00
Write-Host 'git init';
2018-09-11 18:06:54 +00:00
git init
2018-12-14 01:52:14 +00:00
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
2018-09-11 18:06:54 +00:00
git remote add origin $Env:DRONE_REMOTE_URL
}
2018-12-14 01:52:14 +00:00
Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;