Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ PR作業の開始、公開準備、merge後の同期を補助します。
.\scripts\sync_after_merge.ps1 -Branch codex/example-task
```

`publish_pr.ps1` は確認後に `git commit` と `git push` を実行します。PR作成とmergeは自動実行しません。
`publish_pr.ps1` は確認後に `git commit` と `git push` を実行し、`pr_body.md` の生成、クリップボード確認、PR作成URLの表示を行います。クリップボード確認に失敗した場合は `pr_body.md` を開きます。PR作成とmergeは自動実行しません。

## mock TCPサーバーの使い方

Expand Down
4 changes: 4 additions & 0 deletions prompts/codex_task_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
- `logs/real_device/` は実機ログ保存用であり、pytest一時領域には使わない。
- 不明な通信仕様は推測で実装しない。
- 通信仕様に関わる変更が必要な場合は、根拠となる資料と確認事項を先に提示する。
- PowerShellでの確認コマンドは、原則としてCodex側で実行する。
- ユーザーに `git status`、`git branch --show-current`、`.\scripts\dev_check.ps1`、`.\scripts\git_preflight.ps1` などを毎回コピペさせない。
- 実行に承認が必要な操作がある場合は、個別に何度も聞かず、作業内容をまとめて1回だけ確認する。
- 実機通信、`git commit`、`git push`、PR作成、merge は明示許可がない限り実行しない。

## 変更後の報告項目

Expand Down
68 changes: 59 additions & 9 deletions scripts/publish_pr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,58 @@ function Get-PullRequestUrl {
return "https://github.com/$ownerRepo/compare/main...$encodedBranch" + "?expand=1&title=$encodedTitle"
}

function Get-ClipboardText {
try {
return Get-Clipboard -Raw
}
catch {
return (Get-Clipboard | Out-String).TrimEnd()
}
}

function Open-PrBody {
param(
[Parameter(Mandatory = $true)]
[string]$Path
)

try {
Start-Process notepad.exe -ArgumentList $Path
}
catch {
Write-Host "Could not open pr_body.md in notepad: $_" -ForegroundColor Yellow
}
}

function Copy-PrBodyToClipboard {
param(
[Parameter(Mandatory = $true)]
[string]$Path
)

$bodyText = Get-Content -LiteralPath $Path -Raw
$verified = $false

try {
if ((Get-Command Set-Clipboard -ErrorAction SilentlyContinue) -and (Get-Command Get-Clipboard -ErrorAction SilentlyContinue)) {
$bodyText | Set-Clipboard
$clipboardText = Get-ClipboardText
if ($clipboardText -eq $bodyText) {
$verified = $true
Write-Host "Clipboard verified."
}
}
}
catch {
$verified = $false
}

if (-not $verified) {
Write-Host "Clipboard copy could not be verified. Opening pr_body.md." -ForegroundColor Yellow
Open-PrBody -Path $Path
}
}

Push-Location $repoRoot
try {
$branch = git branch --show-current
Expand Down Expand Up @@ -134,21 +186,19 @@ try {
& $prBodyScript -OutputPath $bodyPath
}

try {
if (Get-Command Set-Clipboard -ErrorAction SilentlyContinue) {
Get-Content -LiteralPath $bodyPath -Raw | Set-Clipboard
Write-Host "Copied pr_body.md to clipboard."
}
}
catch {
Write-Host "Could not copy pr_body.md to clipboard: $_" -ForegroundColor Yellow
}
Copy-PrBodyToClipboard -Path $bodyPath

$url = Get-PullRequestUrl -Branch $branch -PrTitle $Title
Write-Host ""
if ($url) {
Write-Host "PR creation URL:"
Write-Host $url
try {
Start-Process $url
}
catch {
Write-Host "Could not open PR creation URL in browser: $_" -ForegroundColor Yellow
}
}
else {
Write-Host "PR URLを推定できませんでした。GitHub上で手動作成してください" -ForegroundColor Yellow
Expand Down
Loading