Atualizacao Pilot_Install

This commit is contained in:
2026-07-21 15:13:40 -03:00
parent a7678f6b92
commit b622804b03

View File

@@ -140,28 +140,59 @@ try {
$env:GIT_TERMINAL_PROMPT = '0' $env:GIT_TERMINAL_PROMPT = '0'
# ===== AUTOATUALIZAÇÃO FORÇADA ===== # ===== AUTOATUALIZAÇÃO =====
Write-Info "Preparando diretório temporário para clone limpo..."
if (Test-Path -LiteralPath $WorkDir) {
Write-Info "Removendo diretório temporário antigo..."
#Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue
#testando se funcionou
}
Ensure-Dir $WorkDir
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) clone --depth 1 --branch $Branch $RepoUrl $WorkDir
if (-not (Test-Path -LiteralPath (Join-Path $WorkDir '.git'))) { if (-not (Test-Path -LiteralPath (Join-Path $WorkDir '.git'))) {
throw "Falha ao clonar repositório."
Write-Info "Primeira execução. Clonando repositório..."
if (Test-Path -LiteralPath $WorkDir) {
Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue
}
Ensure-Dir $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) clone --depth 1 --branch $Branch $RepoUrl $WorkDir
if (-not (Test-Path -LiteralPath (Join-Path $WorkDir '.git'))) {
throw "Falha ao clonar repositório."
}
$NeedCopy = $true
}
else {
Write-Info "Verificando atualizações..."
Push-Location $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) fetch origin $Branch
$LocalCommit = (& git rev-parse HEAD).Trim()
$RemoteCommit = (& git rev-parse ("origin/" + $Branch)).Trim()
if ($LocalCommit -ne $RemoteCommit) {
Write-Info "Nova versão encontrada."
& git reset --hard ("origin/" + $Branch)
$NeedCopy = $true
}
else {
Write-Ok "Repositório já está atualizado."
$NeedCopy = $false
}
Pop-Location
} }
Write-Ok "Clone concluído." if ($NeedCopy) {
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..." Write-Info "Copiando arquivos para $TargetDir..."
$rc = robocopy `
$rc = robocopy `
$WorkDir ` $WorkDir `
$TargetDir ` $TargetDir `
* ` * `
@@ -170,10 +201,17 @@ try {
/XF ".gitignore" ".gitattributes" ` /XF ".gitignore" ".gitattributes" `
/LOG:$CopyLog /LOG:$CopyLog
if ($LASTEXITCODE -ge 8) { if ($LASTEXITCODE -ge 8) {
throw "Falha ao copiar arquivos. Veja o log: $CopyLog" throw "Falha ao copiar arquivos. Veja o log: $CopyLog"
} else { }
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $CopyLog" else {
Write-Ok "Cópia concluída."
}
}
else {
Write-Ok "Nenhuma alteração encontrada."
}
copy: $LASTEXITCODE) Log: $CopyLog"
} }
# ===== FORÇA A ATUALIZAÇÃO DOS ARQUIVOS PRINCIPAIS ===== # ===== FORÇA A ATUALIZAÇÃO DOS ARQUIVOS PRINCIPAIS =====