# ======================================== # Git Status Check Script # 用于关闭 Cursor 前检查是否有未提交的代码 # ======================================== Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " Git Status Check" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" # 切换到项目根目录 $projectRoot = "D:\MyCursor\AIclinicalresearch" if (Test-Path $projectRoot) { Set-Location $projectRoot } else { Write-Host "❌ Project directory not found: $projectRoot" -ForegroundColor Red exit 1 } # 检查Git状态 $status = git status --short if ($status) { Write-Host "⚠️ WARNING: You have uncommitted changes!" -ForegroundColor Red Write-Host "" Write-Host "Uncommitted files:" -ForegroundColor Yellow Write-Host $status Write-Host "" Write-Host "┌─────────────────────────────────────────────────────────┐" -ForegroundColor Red Write-Host "│ ⚠️ Please commit your changes before closing Cursor! │" -ForegroundColor Red Write-Host "│ │" -ForegroundColor Red Write-Host "│ 🔴 Uncommitted code may be lost permanently! │" -ForegroundColor Red Write-Host "└─────────────────────────────────────────────────────────┘" -ForegroundColor Red Write-Host "" Write-Host "Quick commit command:" -ForegroundColor Yellow Write-Host "git add . && git commit -m 'feat: Complete today development' && git push origin master" -ForegroundColor Cyan Write-Host "" exit 1 } else { Write-Host "✅ All changes committed!" -ForegroundColor Green Write-Host "" } # 检查是否有未推送的提交 $unpushed = git log origin/master..HEAD --oneline 2>$null if ($unpushed) { Write-Host "⚠️ WARNING: You have unpushed commits!" -ForegroundColor Yellow Write-Host "" Write-Host "Unpushed commits:" -ForegroundColor Yellow Write-Host $unpushed Write-Host "" Write-Host "Push command:" -ForegroundColor Yellow Write-Host "git push origin master" -ForegroundColor Cyan Write-Host "" } else { Write-Host "✅ All commits pushed to remote!" -ForegroundColor Green Write-Host "" } # 显示最后一次提交 Write-Host "Last commit:" -ForegroundColor Cyan $lastCommit = git log -1 --pretty=format:"%C(yellow)%h%C(reset) - %C(green)%cr%C(reset) - %s" Write-Host $lastCommit Write-Host "" # 显示当前分支 $currentBranch = git branch --show-current Write-Host "Current branch:" -ForegroundColor Cyan Write-Host $currentBranch -ForegroundColor White Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " Check Complete!" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host ""