Adauga sync_romfast.bat/.ps1 pentru sincronizare romfast<->upstream cu optiune de stash

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-09 12:26:16 +03:00
parent 7e4c0154f2
commit 98e1295eec
3 changed files with 127 additions and 0 deletions

2
.gitignore vendored
View File

@@ -20,6 +20,8 @@
#programms #programms
!*.prg !*.prg
!*.fpw !*.fpw
!*.ps1
!*.bat
#header #header
!*.h !*.h

60
sync_romfast.bat Normal file
View File

@@ -0,0 +1,60 @@
@echo off
rem Sincronizeaza romfast cu upstream. Fara /push: doar local. Cu /push: trimite pe Gitea.
setlocal enabledelayedexpansion
cd /d "%~dp0"
for /f "delims=" %%u in ('git remote get-url origin') do set GITHUB=%%u
for /f "delims=" %%u in ('git remote get-url romfast') do set GITEA=%%u
set STASHED=0
set DIRTY=
for /f "delims=" %%s in ('git status --porcelain') do set DIRTY=1
if defined DIRTY (
echo Ai modificari necomise:
git status -s
set /p ANSWER="Ce fac cu ele? (c = commit, s = stash, n = opresc) [c/s/n] "
if /i "!ANSWER!"=="s" (
git stash push -u -m "sync_romfast auto-stash" -- . ":(exclude)sync_romfast.bat" ":(exclude)sync_romfast.ps1" || exit /b 1
set STASHED=1
) else if /i "!ANSWER!"=="c" (
set /p MSG="Mesaj de commit (Enter = mesaj implicit): "
if "!MSG!"=="" set MSG=Actualizari locale inainte de sincronizare
git add -A
git commit -m "!MSG!"
) else (
echo Oprit. Comite sau fa stash manual, apoi ruleaza din nou scriptul.
exit /b 1
)
)
echo GitHub (origin) %GITHUB% --^> master
echo Gitea (romfast) %GITEA% --^> romfast
git fetch origin || exit /b 1
git checkout master || exit /b 1
git merge --ff-only origin/master || (echo master a divergat de origin/master, verifica manual. & exit /b 1)
git checkout romfast || exit /b 1
git merge master || (echo Conflicte la merge master -^> romfast, rezolva manual ^(git status^). & exit /b 1)
git log --oneline -5
if "%STASHED%"=="1" (
echo Restaurez modificarile din stash...
git stash pop || (echo Conflicte la restaurarea stash-ului, rezolva manual ^(git stash list / git stash pop^). & exit /b 1)
)
set DOPUSH=0
if /i "%~1"=="/push" set DOPUSH=1
if "%DOPUSH%"=="0" (
set /p ANSWER="Local la zi. Fac push acum catre Gitea (romfast)? (y/n) "
if /i "!ANSWER!"=="y" set DOPUSH=1
)
if "%DOPUSH%"=="1" (
git push romfast master || exit /b 1
git push romfast romfast || exit /b 1
echo Push facut catre %GITEA%
) else (
echo Push sarit. Inainte de push: DO ReCreate_FoxBin2Prg.prg in VFP9, apoi ruleaza cu /push.
)

65
sync_romfast.ps1 Normal file
View File

@@ -0,0 +1,65 @@
# 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
}