[patch] 修改逻辑: 在用户误触或开了多个GUI程序的时候不能同时建立多个连接 确保一个账号只能建立一个与后端的连接 友好提示的集成review
This commit is contained in:
@@ -396,12 +396,33 @@ jobs:
|
|||||||
git config user.name "Gitea Actions Bot";
|
git config user.name "Gitea Actions Bot";
|
||||||
git config user.email "bot@gitea.local";
|
git config user.email "bot@gitea.local";
|
||||||
|
|
||||||
|
# Ensure we are on the correct branch (not detached HEAD)
|
||||||
|
$BRANCH = "${{ github.ref_name }}";
|
||||||
|
$currentBranch = git rev-parse --abbrev-ref HEAD;
|
||||||
|
Write-Host "Current branch: $currentBranch";
|
||||||
|
Write-Host "Target branch: $BRANCH";
|
||||||
|
|
||||||
|
if ($currentBranch -ne $BRANCH) {
|
||||||
|
Write-Host "WARNING: Not on target branch, checking out...";
|
||||||
|
git checkout $BRANCH;
|
||||||
|
Write-Host "OK: Checked out to $BRANCH";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean up any existing rebase state before starting
|
||||||
|
$rebaseExists = Test-Path ".git/rebase-merge" -Or (Test-Path ".git/rebase-apply");
|
||||||
|
if ($rebaseExists) {
|
||||||
|
Write-Host "WARNING: Found existing rebase state, cleaning up...";
|
||||||
|
git rebase --abort 2>$null;
|
||||||
|
Remove-Item -Path ".git/rebase-merge" -Recurse -Force -ErrorAction SilentlyContinue;
|
||||||
|
Remove-Item -Path ".git/rebase-apply" -Recurse -Force -ErrorAction SilentlyContinue;
|
||||||
|
Write-Host "OK: Rebase state cleaned";
|
||||||
|
}
|
||||||
|
|
||||||
# Check for changes
|
# Check for changes
|
||||||
git add config.py version_history.json;
|
git add config.py version_history.json;
|
||||||
$hasChanges = git diff --staged --quiet;
|
$hasChanges = git diff --staged --quiet;
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
$BRANCH = "${{ github.ref_name }}";
|
|
||||||
Write-Host "Detected changes in version files";
|
Write-Host "Detected changes in version files";
|
||||||
Write-Host "";
|
Write-Host "";
|
||||||
|
|
||||||
@@ -427,14 +448,6 @@ jobs:
|
|||||||
Copy-Item "version_history.json" "version_history.json.new" -Force;
|
Copy-Item "version_history.json" "version_history.json.new" -Force;
|
||||||
Write-Host "Backed up new version files";
|
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)
|
# Pull remote changes (use merge strategy to avoid rebase conflicts)
|
||||||
git pull origin $BRANCH --no-rebase;
|
git pull origin $BRANCH --no-rebase;
|
||||||
|
|
||||||
@@ -486,29 +499,76 @@ jobs:
|
|||||||
Write-Host "";
|
Write-Host "";
|
||||||
Write-Host "Step 5.3: Pushing to remote...";
|
Write-Host "Step 5.3: Pushing to remote...";
|
||||||
|
|
||||||
# Push to remote (retry up to 3 times)
|
# Push to remote (retry up to 3 times with smart strategy)
|
||||||
$pushSuccess = $false;
|
$pushSuccess = $false;
|
||||||
for ($i = 1; $i -le 3; $i++) {
|
for ($i = 1; $i -le 3; $i++) {
|
||||||
Write-Host "Push attempt $i/3...";
|
Write-Host "Push attempt $i/3...";
|
||||||
|
|
||||||
|
# Before each attempt, ensure clean state
|
||||||
|
if ($i -gt 1) {
|
||||||
|
Write-Host "Preparing for retry $i...";
|
||||||
|
|
||||||
|
# Step 1: Clean up any rebase state
|
||||||
|
$rebaseCheck = Test-Path ".git/rebase-merge" -Or (Test-Path ".git/rebase-apply");
|
||||||
|
if ($rebaseCheck) {
|
||||||
|
Write-Host "Cleaning up rebase state...";
|
||||||
|
git rebase --abort 2>$null;
|
||||||
|
Remove-Item -Path ".git/rebase-merge" -Recurse -Force -ErrorAction SilentlyContinue;
|
||||||
|
Remove-Item -Path ".git/rebase-apply" -Recurse -Force -ErrorAction SilentlyContinue;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 2: Ensure on correct branch
|
||||||
|
$currentBranchCheck = git rev-parse --abbrev-ref HEAD;
|
||||||
|
if ($currentBranchCheck -ne $BRANCH) {
|
||||||
|
Write-Host "Checking out to branch $BRANCH...";
|
||||||
|
git checkout $BRANCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 3: Fetch latest remote state
|
||||||
|
Write-Host "Fetching latest remote state...";
|
||||||
|
git fetch origin $BRANCH;
|
||||||
|
|
||||||
|
# Step 4: Backup our version files again
|
||||||
|
Copy-Item "config.py" "config.py.retry" -Force;
|
||||||
|
Copy-Item "version_history.json" "version_history.json.retry" -Force;
|
||||||
|
|
||||||
|
# Step 5: Reset to remote state
|
||||||
|
Write-Host "Resetting to remote state...";
|
||||||
|
git reset --hard origin/$BRANCH;
|
||||||
|
|
||||||
|
# Step 6: Apply our version files
|
||||||
|
Write-Host "Applying our version files...";
|
||||||
|
Copy-Item "config.py.retry" "config.py" -Force;
|
||||||
|
Copy-Item "version_history.json.retry" "version_history.json" -Force;
|
||||||
|
|
||||||
|
# Step 7: Stage and commit again
|
||||||
|
git add config.py version_history.json;
|
||||||
|
git commit -m "[skip ci] Update version to v$VERSION" --no-verify;
|
||||||
|
|
||||||
|
# Step 8: Clean up retry backup files
|
||||||
|
Remove-Item "config.py.retry" -ErrorAction SilentlyContinue;
|
||||||
|
Remove-Item "version_history.json.retry" -ErrorAction SilentlyContinue;
|
||||||
|
|
||||||
|
Write-Host "Retry preparation complete";
|
||||||
|
Start-Sleep -Seconds 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Attempt to push
|
||||||
git push origin $BRANCH;
|
git push origin $BRANCH;
|
||||||
|
|
||||||
if ($LASTEXITCODE -eq 0) {
|
if ($LASTEXITCODE -eq 0) {
|
||||||
Write-Host "OK: Push successful";
|
Write-Host "OK: Push successful on attempt $i";
|
||||||
$pushSuccess = $true;
|
$pushSuccess = $true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
Write-Host "WARNING: Push failed";
|
Write-Host "WARNING: Push attempt $i failed";
|
||||||
if ($i -lt 3) {
|
|
||||||
Write-Host "Pulling again and retrying...";
|
|
||||||
git pull --rebase origin $BRANCH;
|
|
||||||
Start-Sleep -Seconds 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $pushSuccess) {
|
if (-not $pushSuccess) {
|
||||||
Write-Host "ERROR: Push failed after 3 attempts";
|
Write-Host "ERROR: Push failed after 3 attempts";
|
||||||
Write-Host "This is not critical - version is already recorded in database";
|
Write-Host "NOTICE: This is not critical - version is already in database and KS3";
|
||||||
|
Write-Host "NOTICE: Git repository sync can be done manually later";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "ERROR: Commit failed";
|
Write-Host "ERROR: Commit failed";
|
||||||
|
|||||||
Reference in New Issue
Block a user