diff --git a/README.md b/README.md index 6c1f8c9..5e89409 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,29 @@ pytest を実行します。 py -m pytest ``` +## 半自動チェック + +開発中の基本確認をまとめて実行します。 + +```powershell +.\scripts\dev_check.ps1 +``` + +PR作成前の確認をまとめて表示します。 + +```powershell +.\scripts\git_preflight.ps1 +``` + +PR本文テンプレートを表示、またはファイルへ保存します。 + +```powershell +.\scripts\pr_body.ps1 +.\scripts\pr_body.ps1 -OutputPath pr_body.md +``` + +これらのスクリプトは実機通信、`real_device_check.py`、`git push`、PR作成、mergeを自動実行しません。 + ## mock TCPサーバーの使い方 UTRリーダライタ実機の代わりに、localhost 上で mock TCPサーバーを起動できます。 diff --git a/prompts/pr_body_template.md b/prompts/pr_body_template.md new file mode 100644 index 0000000..f210293 --- /dev/null +++ b/prompts/pr_body_template.md @@ -0,0 +1,22 @@ +## Summary + +- + +## Test + +- [ ] `.\scripts\dev_check.ps1` +- [ ] pytest completed +- [ ] blocked text scan completed +- [ ] `logs/real_device/` ignore check completed + +## Safety + +- [ ] No real device communication +- [ ] `real_device_check.py` not executed +- [ ] `logs/real_device/` is excluded from Git +- [ ] `git push` not executed +- [ ] PR creation and merge are manual + +## Notes + +- diff --git a/scripts/git_preflight.ps1 b/scripts/git_preflight.ps1 new file mode 100644 index 0000000..7749abb --- /dev/null +++ b/scripts/git_preflight.ps1 @@ -0,0 +1,66 @@ +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" + +$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..") +$failed = $false + +function Invoke-Check { + param( + [Parameter(Mandatory = $true)] + [string]$Title, + + [Parameter(Mandatory = $true)] + [scriptblock]$Command + ) + + Write-Host "" + Write-Host "== $Title ==" + + try { + $global:LASTEXITCODE = 0 + & $Command + if ($LASTEXITCODE -ne 0) { + throw "Exit code $LASTEXITCODE" + } + } + catch { + Write-Host "ERROR: $Title failed: $_" -ForegroundColor Red + $script:failed = $true + } +} + +Push-Location $repoRoot +try { + Invoke-Check "current branch" { + git branch --show-current + } + + Invoke-Check "git status --short" { + git status --short + } + + Invoke-Check "git diff --stat" { + git diff --stat + } + + Invoke-Check "git log --oneline --decorate -5" { + git log --oneline --decorate -5 + } + + $devCheckScript = Join-Path $PSScriptRoot "dev_check.ps1" + Invoke-Check "dev_check.ps1" { + & $devCheckScript + } +} +finally { + Pop-Location +} + +if ($failed) { + Write-Host "ERROR: git_preflight failed." -ForegroundColor Red + exit 1 +} + +Write-Host "" +Write-Host "git_preflight passed." +exit 0 diff --git a/scripts/pr_body.ps1 b/scripts/pr_body.ps1 new file mode 100644 index 0000000..ec19271 --- /dev/null +++ b/scripts/pr_body.ps1 @@ -0,0 +1,46 @@ +param( + [string]$OutputPath +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" + +$body = @' +## Summary + +- + +## Test + +- [ ] `.\scripts\dev_check.ps1` +- [ ] pytest completed +- [ ] blocked text scan completed +- [ ] `logs/real_device/` ignore check completed + +## Safety + +- [ ] No real device communication +- [ ] `real_device_check.py` not executed +- [ ] `logs/real_device/` is excluded from Git +- [ ] `git push` not executed +- [ ] PR creation and merge are manual + +## Notes + +- +'@ + +if ($OutputPath) { + $parent = Split-Path -Parent $OutputPath + if ($parent -and -not (Test-Path -LiteralPath $parent)) { + Write-Error "Output directory does not exist: $parent" + exit 1 + } + + Set-Content -LiteralPath $OutputPath -Value $body -Encoding UTF8 + Write-Host "PR body template written to: $OutputPath" + exit 0 +} + +Write-Output $body +exit 0