Update sync script: remove auto-push and fix encoding issues

This commit is contained in:
xudan 2025-06-16 10:39:47 +08:00
parent 9a31a835ed
commit d495296cd8

View File

@ -1,5 +1,4 @@
# Git Multi-Repository Sync Script (PowerShell)
# For syncing mirror repository to your personal repository
param(
[switch]$UseRebase = $false,
@ -58,6 +57,7 @@ function Sync-Repositories {
git rebase upstream/master
if ($LASTEXITCODE -ne 0) {
Write-ColorOutput "Rebase failed! Please resolve conflicts manually." "Red"
Write-ColorOutput "After resolving conflicts, run: git rebase --continue" "Yellow"
return
}
} else {
@ -69,6 +69,7 @@ function Sync-Repositories {
git merge upstream/master
if ($LASTEXITCODE -ne 0) {
Write-ColorOutput "Merge failed! Please resolve conflicts manually." "Red"
Write-ColorOutput "After resolving conflicts, run: git commit" "Yellow"
return
}
} else {
@ -76,24 +77,14 @@ function Sync-Repositories {
}
}
# Push to your repository
Write-ColorOutput "Pushing to your repository..." "Green"
if (-not $DryRun) {
if ($UseRebase) {
git push origin master --force-with-lease
} else {
git push origin master
}
if ($LASTEXITCODE -ne 0) {
Write-ColorOutput "Push failed!" "Red"
return
}
} else {
$pushCmd = if ($UseRebase) { "git push origin master --force-with-lease" } else { "git push origin master" }
Write-ColorOutput "[DRY RUN] $pushCmd" "Gray"
Write-ColorOutput "Sync completed successfully!" "Green"
Write-ColorOutput ""
Write-ColorOutput "Next steps:" "Cyan"
Write-ColorOutput " Please manually push to your repository: git push origin master" "White"
if ($UseRebase) {
Write-ColorOutput " (If using rebase, you might need: git push origin master --force-with-lease)" "Yellow"
}
Write-ColorOutput "Sync completed successfully!" "Green"
} else {
Write-ColorOutput "No new commits from upstream. Checking for local changes..." "Blue"
@ -103,17 +94,9 @@ function Sync-Repositories {
Write-ColorOutput "Found local changes to push:" "Yellow"
Write-ColorOutput $localCommits "Gray"
Write-ColorOutput "Pushing local changes..." "Green"
if (-not $DryRun) {
git push origin master
if ($LASTEXITCODE -ne 0) {
Write-ColorOutput "Push failed!" "Red"
return
}
} else {
Write-ColorOutput "[DRY RUN] git push origin master" "Gray"
}
Write-ColorOutput "Push completed!" "Green"
Write-ColorOutput ""
Write-ColorOutput "Next steps:" "Cyan"
Write-ColorOutput " Please manually push to your repository: git push origin master" "White"
} else {
Write-ColorOutput "Nothing to sync." "Blue"
}
@ -133,6 +116,8 @@ function Show-Help {
Write-ColorOutput " .\sync-repos.ps1 # Sync using merge" "White"
Write-ColorOutput " .\sync-repos.ps1 -UseRebase # Sync using rebase" "White"
Write-ColorOutput " .\sync-repos.ps1 -DryRun # Preview mode" "White"
Write-ColorOutput ""
Write-ColorOutput "Note: Script will NOT automatically push to your repository." "Yellow"
}
# Main program