git-docker/windows/windows_gen.go

127 lines
3.2 KiB
Go

package windows
// DO NOT EDIT. This file is automatically generated.
// Contents of clone.ps1
const Clone = `$ErrorActionPreference = 'Stop';
# HACK: no clue how to set the PATH inside the Dockerfile,
# so am setting it here instead. This is not idea.
$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin'
# if the workspace is set we should make sure
# it is the current working directory.
if ($Env:DRONE_WORKSPACE) {
cd $Env:DRONE_WORKSPACE
}
# if the netrc enviornment variables exist, write
# the netrc file.
if ($Env:DRONE_NETRC_MACHINE) {
@"
machine $Env:DRONE_NETRC_MACHINE
login $Env:DRONE_NETRC_USERNAME
password $Env:DRONE_NETRC_PASSWORD
"@ > (Join-Path $Env:USERPROFILE '_netrc');
}
# configure git global behavior and parameters via the
# following environment variables:
if ($Env:PLUGIN_SKIP_VERIFY) {
$Env:GIT_SSL_NO_VERIFY = "true"
}
if ($Env:DRONE_COMMIT_AUTHOR_NAME -eq '' -or $Env:DRONE_COMMIT_AUTHOR_NAME -eq $null) {
$Env:GIT_AUTHOR_NAME = "drone"
} else {
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
}
if ($Env:DRONE_COMMIT_AUTHOR_EMAIL -eq '' -or $Env:DRONE_COMMIT_AUTHOR_EMAIL -eq $null) {
$Env:GIT_AUTHOR_EMAIL = 'drone@localhost'
} else {
$Env:GIT_AUTHOR_EMAIL = $Env:DRONE_COMMIT_AUTHOR_EMAIL
}
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
$Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
# invoke the sub-script based on the drone event type.
# TODO we should ultimately look at the ref, since
# we need something compatible with deployment events.
switch ($Env:DRONE_BUILD_EVENT) {
"pull_request" {
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
break
}
"tag" {
Invoke-Expression "${PSScriptRoot}\clone-tag.ps1"
break
}
default {
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
break
}
}
`
// Contents of clone-commit.ps1
const CloneCommit = `
Set-Variable -Name "FLAGS" -Value ""
if ($Env:PLUGIN_DEPTH) {
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
}
if (!(Test-Path .git)) {
Write-Host 'git init';
git init
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
git remote add origin $Env:DRONE_REMOTE_URL
}
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;
`
// Contents of clone-pull-request.ps1
const ClonePullRequest = `
Set-Variable -Name "FLAGS" -Value ""
if ($Env:PLUGIN_DEPTH) {
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
}
if (!(Test-Path .git)) {
git init
git remote add origin $Env:DRONE_REMOTE_URL
}
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
git checkout $Env:DRONE_COMMIT_BRANCH
git fetch origin "${Env:DRONE_COMMIT_REF}:"
git merge $Env:DRONE_COMMIT_SHA
`
// Contents of clone-tag.ps1
const CloneTag = `
Set-Variable -Name "FLAGS" -Value ""
if ($Env:PLUGIN_DEPTH) {
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
}
if (!(Test-Path .git)) {
git init
git remote add origin $Env:DRONE_REMOTE_URL
}
git fetch $FLAGS origin "+refs/tags/${Env:DRONE_TAG}:"
git checkout -qf FETCH_HEAD
`