You've already forked git-docker
embed files [CI SKIP]
This commit is contained in:
3
windows/windows.go
Normal file
3
windows/windows.go
Normal file
@ -0,0 +1,3 @@
|
||||
package windows
|
||||
|
||||
//go:generate go run ../scripts/includetext.go --input=clone.ps1 --input=clone-commit.ps1 --input=clone-pull-request.ps1 --input=clone-tag.ps1 --package=windows --output=windows_gen.go
|
125
windows/windows_gen.go
Normal file
125
windows/windows_gen.go
Normal file
@ -0,0 +1,125 @@
|
||||
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) {
|
||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_NAME = "drone"
|
||||
}
|
||||
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME) {
|
||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_NAME = 'drone@localhost'
|
||||
}
|
||||
|
||||
$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 rebase $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
|
||||
`
|
Reference in New Issue
Block a user