34 lines
1.3 KiB
PowerShell
34 lines
1.3 KiB
PowerShell
# One-shot: commit pending changes, then force-with-lease push feat/web-game to fork (remote: karylab).
|
|
# --force-with-lease fails instead of overwriting if the remote moved since our fetch; never use plain -f.
|
|
# Usage: powershell -ExecutionPolicy Bypass -File scripts\push_force_feat_web_game.ps1
|
|
$ErrorActionPreference = 'Stop'
|
|
Set-Location (Join-Path $PSScriptRoot '..')
|
|
|
|
$git = Get-Command git -ErrorAction SilentlyContinue
|
|
if (-not $git) {
|
|
$git = 'C:\Users\ckliu\.cache\codex-runtimes\codex-primary-runtime\dependencies\native\git\cmd\git.exe'
|
|
} else { $git = $git.Source }
|
|
|
|
Write-Host '== Status before =='
|
|
& $git status --short
|
|
|
|
Write-Host ''
|
|
Write-Host '== Commit pending changes if any =='
|
|
$porcelain = (& $git status --porcelain).Trim()
|
|
if ($porcelain -ne '') {
|
|
& $git add -A
|
|
if ($LASTEXITCODE -ne 0) { throw 'git add failed' }
|
|
& $git commit -m 'chore(scripts): ps1 UTF-8 BOM encoding + push helper scripts'
|
|
if ($LASTEXITCODE -ne 0) { throw 'git commit failed' }
|
|
} else {
|
|
Write-Host '(no pending changes)'
|
|
}
|
|
|
|
Write-Host ''
|
|
Write-Host '== Force-with-lease push (fails instead of overwriting if remote moved) =='
|
|
& $git push --force-with-lease karylab feat/web-game
|
|
if ($LASTEXITCODE -ne 0) { throw 'push failed (remote may have moved; do not use plain -f)' }
|
|
|
|
Write-Host ''
|
|
Write-Host '== Done =='
|
|
& $git log --oneline -1 |