Fixed cross linked device failing move of .git dir

This commit is contained in:
lksz 2020-10-02 14:23:54 -04:00
parent e14f00d98d
commit fe97c2880a
1 changed files with 9 additions and 1 deletions

View File

@ -55,7 +55,15 @@ Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { .
$local:GitOutput = "$(& git clone $GitURL $tmpGitDir.FullName --no-checkout)" $local:GitOutput = "$(& git clone $GitURL $tmpGitDir.FullName --no-checkout)"
Write-Verbose $GitOutput Write-Verbose $GitOutput
Write-Verbose "Moving git repo from temp location to $MyPSScriptRoot . . ." Write-Verbose "Moving git repo from temp location to $MyPSScriptRoot . . ."
Move-Item (Join-Path $tmpGitDir.FullName .git) ./.git try {
Move-Item (Join-Path $tmpGitDir.FullName .git) ./.git -ErrorAction Stop
} catch {
if( $_.Exception.Message -eq "Invalid cross-device link" ) {
Copy-Item -Recurse (Join-Path $tmpGitDir.FullName .git) ./.git
} else {
throw $_
}
}
Remove-Item $tmpGitDir.FullName Remove-Item $tmpGitDir.FullName
Write-Verbose "Checking out repo..." Write-Verbose "Checking out repo..."
$GitOutput = "$(& git checkout --force)" $GitOutput = "$(& git checkout --force)"