66 lines
2.2 KiB
PowerShell
66 lines
2.2 KiB
PowerShell
# Sincronizeaza romfast cu upstream. Fara -Push: doar local. Cu -Push: trimite pe Gitea.
|
|
param([switch]$Push)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
Set-Location $PSScriptRoot
|
|
|
|
$GITHUB = git remote get-url origin
|
|
$GITEA = git remote get-url romfast
|
|
|
|
$stashed = $false
|
|
$dirty = git status --porcelain
|
|
if ($dirty) {
|
|
Write-Host "Ai modificari necomise:" -ForegroundColor Yellow
|
|
git status -s
|
|
$answer = Read-Host "Ce fac cu ele? (c = commit, s = stash, n = opresc) [c/s/n]"
|
|
switch ($answer) {
|
|
's' {
|
|
git stash push -u -m "sync_romfast auto-stash" -- . ":(exclude)sync_romfast.bat" ":(exclude)sync_romfast.ps1"
|
|
$stashed = $true
|
|
}
|
|
'c' {
|
|
$msg = Read-Host "Mesaj de commit (Enter = mesaj implicit)"
|
|
if (-not $msg) { $msg = "Actualizari locale inainte de sincronizare" }
|
|
git add -A
|
|
git commit -m $msg
|
|
}
|
|
default {
|
|
Write-Host "Oprit. Comite sau fa stash manual, apoi ruleaza din nou scriptul." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host "GitHub (origin) $GITHUB --> master" -ForegroundColor Cyan
|
|
Write-Host "Gitea (romfast) $GITEA --> romfast" -ForegroundColor Cyan
|
|
|
|
git fetch origin
|
|
git checkout master
|
|
git merge --ff-only origin/master
|
|
if ($LASTEXITCODE -ne 0) { throw "master a divergat de origin/master, verifica manual." }
|
|
|
|
git checkout romfast
|
|
git merge master
|
|
if ($LASTEXITCODE -ne 0) { throw "Conflicte la merge master -> romfast, rezolva manual (git status)." }
|
|
|
|
git log --oneline -5
|
|
|
|
if ($stashed) {
|
|
Write-Host "Restaurez modificarile din stash..." -ForegroundColor Cyan
|
|
git stash pop
|
|
if ($LASTEXITCODE -ne 0) { throw "Conflicte la restaurarea stash-ului, rezolva manual (git stash list / git stash pop)." }
|
|
}
|
|
|
|
if (-not $Push) {
|
|
$answer = Read-Host "Local la zi. Fac push acum catre Gitea (romfast)? (y/n)"
|
|
if ($answer -eq 'y') { $Push = $true }
|
|
}
|
|
|
|
if ($Push) {
|
|
git push romfast master
|
|
git push romfast romfast
|
|
Write-Host "Push facut catre $GITEA" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "Push sarit. Inainte de push: DO ReCreate_FoxBin2Prg.prg in VFP9, apoi ruleaza cu -Push." -ForegroundColor Yellow
|
|
}
|