fixed git checkout script
This commit is contained in:
parent
1a2f1e2108
commit
5b0d53313d
2 changed files with 14 additions and 13 deletions
|
@ -43,7 +43,7 @@ function Invoke-Call {
|
|||
[scriptblock]$ScriptBlock,
|
||||
[string]$ErrorAction = $ErrorActionPreference
|
||||
)
|
||||
& @ScriptBlock 2>&1 | %{ "$_" }
|
||||
& @ScriptBlock 2>&1 3>&1 4>&1| ForEach-Object { "$_" }
|
||||
if (($lastexitcode -ne 0) -and $ErrorAction -eq "Stop") {
|
||||
Write-Error "Command $ScriptBlock exited with $lastexitcode."
|
||||
exit $lastexitcode
|
||||
|
|
|
@ -14,25 +14,26 @@
|
|||
|
||||
. ${PSScriptRoot}\common.ps1
|
||||
|
||||
Set-PSDebug -Trace 1
|
||||
#Set-PSDebug -Trace 1
|
||||
|
||||
# Wrap git commant in error handling function
|
||||
function Invoke-Git
|
||||
{
|
||||
param (
|
||||
[scriptblock]$args
|
||||
)
|
||||
Invoke-Call -ScriptBlock { git $args } -ErrorAction Stop
|
||||
function Invoke-Git($cmd) {
|
||||
Invoke-Call -ScriptBlock { git @cmd } -ErrorAction Stop
|
||||
}
|
||||
|
||||
if (Test-Path -PathType Container "llvm-project"){
|
||||
Set-Location llvm-project
|
||||
Write-Output "performing git pull..."
|
||||
Invoke-Git checkout master
|
||||
Invoke-Git reset
|
||||
Invoke-Git clean -fdx
|
||||
Invoke-Git pull
|
||||
$branch = (git branch) | Out-String
|
||||
$branch = ($branch -split '\r')[0]
|
||||
if ($branch -ne "* master"){
|
||||
Invoke-Call -ScriptBlock { git checkout master} -ErrorAction Stop
|
||||
}
|
||||
Invoke-Call -ScriptBlock { git reset --hard } -ErrorAction Stop
|
||||
Invoke-Call -ScriptBlock { git clean -fdx } -ErrorAction Stop
|
||||
Invoke-Call -ScriptBlock { git pull } -ErrorAction Stop
|
||||
# TODO: in case of errors: delete folder and clone
|
||||
} else {
|
||||
Write-Output "performing git clone..."
|
||||
Invoke-Git clone -q --depth 1 https://github.com/llvm/llvm-project
|
||||
Invoke-Call -ScriptBlock { git clone -q --depth 1 https://github.com/llvm/llvm-project } -ErrorAction Stop
|
||||
}
|
Loading…
Reference in a new issue