From 4f17092305e1f73e7c19b28d751d5bbaf6895022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kris=20=E9=83=9D?= <1652570799@qq.com> Date: Mon, 3 Nov 2025 15:51:00 +0800 Subject: [PATCH] =?UTF-8?q?[patch]=20=E4=BF=AE=E5=A4=8D=E5=9B=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=9B=B4=E6=96=B0=E5=9B=9E=E5=BD=92=E4=BB=A3=E7=A0=81?= =?UTF-8?q?config.py=E5=9B=A0=E8=A6=86=E7=9B=96=E9=80=BB=E8=BE=91=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=A0=81=E8=A2=AB?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/gui-version-release.yml | 40 +++++++++++++++--------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/gui-version-release.yml b/.gitea/workflows/gui-version-release.yml index bda11f4..7b21599 100644 --- a/.gitea/workflows/gui-version-release.yml +++ b/.gitea/workflows/gui-version-release.yml @@ -472,17 +472,22 @@ jobs: Write-Host "Remote: $REMOTE"; Write-Host ""; - # Unstage to avoid merge conflicts - git reset HEAD config.py version_history.json; - - # FIX: No longer backup files to avoid overwriting user code later - Write-Host "Preparing to pull remote changes..."; + # FIX: Stash local changes before pull to avoid conflicts + Write-Host "Stashing local version changes..."; + git stash push -m "CI-CD-temp-stash" config.py version_history.json; + Write-Host "Pulling remote changes..."; # Pull remote changes (use merge strategy to avoid rebase conflicts) git pull origin $BRANCH --no-rebase; - if ($LASTEXITCODE -ne 0) { - Write-Host "WARNING: Pull failed, attempting manual conflict resolution..."; + # Pop stashed changes back + 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 $conflicts = git diff --name-only --diff-filter=U; @@ -508,16 +513,15 @@ jobs: Write-Host "OK: Resolved version_history.json (using CI/CD version)"; } - # Complete the merge - git commit -m "[skip ci] Merge and update version to v$VERSION" --no-edit --no-verify; + # Drop the stash after resolving + git stash drop 2>$null; } 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 - # After pull, config.py already contains: - # 1. Version update from CI/CD (gui_version_creator.py) - # 2. User's new code (from remote repository) - # Just add current state, no need to overwrite + # FIX: After stash pop, files are automatically merged + # config.py now contains: + # 1. User's code from remote (from pull) + # 2. Version update from stash (from gui_version_creator.py) Write-Host "Checking if version update is preserved..."; @@ -539,9 +543,15 @@ jobs: # Add current files (includes user code + version update) git add config.py version_history.json; + + Write-Host "Files staged successfully"; } } else { 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 "";