[patch] 修改逻辑: 在用户误触或开了多个GUI程序的时候不能同时建立多个连接 确保一个账号只能建立一个与后端的连接 友好提示的集成review
This commit is contained in:
@@ -2,7 +2,7 @@ name: GUI Version Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, develop ] # 临时添加 develop 用于测试
|
||||
branches: [ master, develop ] # Trigger on master and develop branches
|
||||
|
||||
jobs:
|
||||
gui-version-release:
|
||||
@@ -378,8 +378,11 @@ jobs:
|
||||
if: success()
|
||||
shell: powershell
|
||||
run: |
|
||||
Write-Host "Committing version changes...";
|
||||
Write-Host "========================================";
|
||||
Write-Host "Step 5: Commit version changes";
|
||||
Write-Host "========================================";
|
||||
|
||||
# Read new version number
|
||||
$VERSION = "";
|
||||
if (Test-Path "config.py") {
|
||||
$configContent = Get-Content "config.py" -Raw;
|
||||
@@ -389,38 +392,134 @@ jobs:
|
||||
}
|
||||
}
|
||||
|
||||
# Configure Git
|
||||
git config user.name "Gitea Actions Bot";
|
||||
git config user.email "bot@gitea.local";
|
||||
|
||||
Write-Host "Adding files...";
|
||||
git add config.py;
|
||||
git add version_history.json;
|
||||
|
||||
Write-Host "Checking changes...";
|
||||
git status;
|
||||
|
||||
# Check for changes
|
||||
git add config.py version_history.json;
|
||||
$hasChanges = git diff --staged --quiet;
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$BRANCH = "${{ github.ref_name }}";
|
||||
Write-Host "Committing to branch: $BRANCH";
|
||||
Write-Host "Detected changes in version files";
|
||||
Write-Host "";
|
||||
|
||||
git commit -m "[skip ci] Update version to v$VERSION";
|
||||
# KEY CHANGE: Pull first, then commit
|
||||
Write-Host "Step 5.1: Pulling latest changes first...";
|
||||
git fetch origin $BRANCH;
|
||||
|
||||
Write-Host "Pulling latest changes before push...";
|
||||
git pull --rebase origin $BRANCH;
|
||||
# Check if remote has updates
|
||||
$LOCAL = git rev-parse HEAD;
|
||||
$REMOTE = git rev-parse origin/$BRANCH;
|
||||
|
||||
if ($LOCAL -ne $REMOTE) {
|
||||
Write-Host "Remote has new commits, need to merge...";
|
||||
Write-Host "Local: $LOCAL";
|
||||
Write-Host "Remote: $REMOTE";
|
||||
Write-Host "";
|
||||
|
||||
# Unstage to avoid merge conflicts
|
||||
git reset HEAD config.py version_history.json;
|
||||
|
||||
# Backup our version files
|
||||
Copy-Item "config.py" "config.py.new" -Force;
|
||||
Copy-Item "version_history.json" "version_history.json.new" -Force;
|
||||
Write-Host "Backed up new version files";
|
||||
|
||||
# Check for interrupted rebase
|
||||
$rebaseInProgress = Test-Path ".git/rebase-merge" -Or (Test-Path ".git/rebase-apply");
|
||||
if ($rebaseInProgress) {
|
||||
Write-Host "WARNING: Detected interrupted rebase, aborting...";
|
||||
git rebase --abort;
|
||||
Write-Host "OK: Rebase aborted, starting clean";
|
||||
}
|
||||
|
||||
# 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...";
|
||||
|
||||
# Check conflict files
|
||||
$conflicts = git diff --name-only --diff-filter=U;
|
||||
Write-Host "Conflict files: $conflicts";
|
||||
|
||||
# Manually resolve config.py conflict (use our new version)
|
||||
if (Test-Path "config.py.new") {
|
||||
Copy-Item "config.py.new" "config.py" -Force;
|
||||
git add config.py;
|
||||
Write-Host "OK: Resolved config.py conflict (using new version)";
|
||||
}
|
||||
|
||||
# Manually resolve version_history.json conflict (use our new version)
|
||||
if (Test-Path "version_history.json.new") {
|
||||
Copy-Item "version_history.json.new" "version_history.json" -Force;
|
||||
git add version_history.json;
|
||||
Write-Host "OK: Resolved version_history.json conflict (using new version)";
|
||||
}
|
||||
|
||||
# Complete the merge
|
||||
git commit -m "[skip ci] Merge and update version to v$VERSION" --no-edit --no-verify;
|
||||
} else {
|
||||
Write-Host "OK: Pull successful, applying our changes...";
|
||||
|
||||
# Apply our version files
|
||||
Copy-Item "config.py.new" "config.py" -Force;
|
||||
Copy-Item "version_history.json.new" "version_history.json" -Force;
|
||||
git add config.py version_history.json;
|
||||
}
|
||||
|
||||
# Cleanup backup files
|
||||
Remove-Item "config.py.new" -ErrorAction SilentlyContinue;
|
||||
Remove-Item "version_history.json.new" -ErrorAction SilentlyContinue;
|
||||
} else {
|
||||
Write-Host "No remote changes, proceeding with commit...";
|
||||
}
|
||||
|
||||
Write-Host "";
|
||||
Write-Host "Step 5.2: Committing version changes...";
|
||||
git commit -m "[skip ci] Update version to v$VERSION" --no-verify;
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "Pushing changes...";
|
||||
Write-Host "OK: Commit successful";
|
||||
Write-Host "";
|
||||
Write-Host "Step 5.3: Pushing to remote...";
|
||||
|
||||
# Push to remote (retry up to 3 times)
|
||||
$pushSuccess = $false;
|
||||
for ($i = 1; $i -le 3; $i++) {
|
||||
Write-Host "Push attempt $i/3...";
|
||||
git push origin $BRANCH;
|
||||
Write-Host "Changes committed and pushed";
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "OK: Push successful";
|
||||
$pushSuccess = $true;
|
||||
break;
|
||||
} else {
|
||||
Write-Host "Pull failed, trying force push...";
|
||||
git push origin $BRANCH;
|
||||
Write-Host "WARNING: Push failed";
|
||||
if ($i -lt 3) {
|
||||
Write-Host "Pulling again and retrying...";
|
||||
git pull --rebase origin $BRANCH;
|
||||
Start-Sleep -Seconds 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $pushSuccess) {
|
||||
Write-Host "ERROR: Push failed after 3 attempts";
|
||||
Write-Host "This is not critical - version is already recorded in database";
|
||||
}
|
||||
} else {
|
||||
Write-Host "ERROR: Commit failed";
|
||||
}
|
||||
} else {
|
||||
Write-Host "No changes to commit";
|
||||
}
|
||||
|
||||
Write-Host "========================================";
|
||||
Write-Host "";
|
||||
|
||||
# Step 6: Display summary
|
||||
- name: Display summary
|
||||
if: always()
|
||||
|
||||
Reference in New Issue
Block a user