[patch] 修复因自动更新回归代码config.py因覆盖逻辑导致的新增代码被覆盖的逻辑
This commit is contained in:
@@ -472,17 +472,22 @@ jobs:
|
|||||||
Write-Host "Remote: $REMOTE";
|
Write-Host "Remote: $REMOTE";
|
||||||
Write-Host "";
|
Write-Host "";
|
||||||
|
|
||||||
# Unstage to avoid merge conflicts
|
# FIX: Stash local changes before pull to avoid conflicts
|
||||||
git reset HEAD config.py version_history.json;
|
Write-Host "Stashing local version changes...";
|
||||||
|
git stash push -m "CI-CD-temp-stash" config.py version_history.json;
|
||||||
# FIX: No longer backup files to avoid overwriting user code later
|
|
||||||
Write-Host "Preparing to pull remote changes...";
|
|
||||||
|
|
||||||
|
Write-Host "Pulling remote changes...";
|
||||||
# Pull remote changes (use merge strategy to avoid rebase conflicts)
|
# Pull remote changes (use merge strategy to avoid rebase conflicts)
|
||||||
git pull origin $BRANCH --no-rebase;
|
git pull origin $BRANCH --no-rebase;
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
# Pop stashed changes back
|
||||||
Write-Host "WARNING: Pull failed, attempting manual conflict resolution...";
|
Write-Host "Restoring version changes...";
|
||||||
|
$stashPopResult = git stash pop 2>&1;
|
||||||
|
$stashPopExitCode = $LASTEXITCODE;
|
||||||
|
|
||||||
|
if ($stashPopExitCode -ne 0) {
|
||||||
|
Write-Host "WARNING: Stash pop encountered conflicts, resolving...";
|
||||||
|
Write-Host "$stashPopResult";
|
||||||
|
|
||||||
# Check conflict files
|
# Check conflict files
|
||||||
$conflicts = git diff --name-only --diff-filter=U;
|
$conflicts = git diff --name-only --diff-filter=U;
|
||||||
@@ -508,16 +513,15 @@ jobs:
|
|||||||
Write-Host "OK: Resolved version_history.json (using CI/CD version)";
|
Write-Host "OK: Resolved version_history.json (using CI/CD version)";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Complete the merge
|
# Drop the stash after resolving
|
||||||
git commit -m "[skip ci] Merge and update version to v$VERSION" --no-edit --no-verify;
|
git stash drop 2>$null;
|
||||||
} else {
|
} else {
|
||||||
Write-Host "OK: Pull successful";
|
Write-Host "OK: Stash pop successful";
|
||||||
|
|
||||||
# FIX: Do not overwrite entire file to avoid losing user's new code
|
# FIX: After stash pop, files are automatically merged
|
||||||
# After pull, config.py already contains:
|
# config.py now contains:
|
||||||
# 1. Version update from CI/CD (gui_version_creator.py)
|
# 1. User's code from remote (from pull)
|
||||||
# 2. User's new code (from remote repository)
|
# 2. Version update from stash (from gui_version_creator.py)
|
||||||
# Just add current state, no need to overwrite
|
|
||||||
|
|
||||||
Write-Host "Checking if version update is preserved...";
|
Write-Host "Checking if version update is preserved...";
|
||||||
|
|
||||||
@@ -539,9 +543,15 @@ jobs:
|
|||||||
|
|
||||||
# Add current files (includes user code + version update)
|
# Add current files (includes user code + version update)
|
||||||
git add config.py version_history.json;
|
git add config.py version_history.json;
|
||||||
|
|
||||||
|
Write-Host "Files staged successfully";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "No remote changes, proceeding with commit...";
|
Write-Host "No remote changes, proceeding with commit...";
|
||||||
|
|
||||||
|
# FIX: Ensure files are staged even if no remote changes
|
||||||
|
git add config.py version_history.json;
|
||||||
|
Write-Host "Files staged for commit";
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "";
|
Write-Host "";
|
||||||
|
|||||||
Reference in New Issue
Block a user