Skip to content

feat(scripts): collect PR URLs and prompt once at end of run#10

Merged
sksizer merged 1 commit into
mainfrom
feat/defer-pr-open-prompt
Apr 7, 2026
Merged

feat(scripts): collect PR URLs and prompt once at end of run#10
sksizer merged 1 commit into
mainfrom
feat/defer-pr-open-prompt

Conversation

@sksizer

@sksizer sksizer commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Summary

Stops the update scripts from opening browser tabs the moment each PR is created. Instead, URLs are collected and the user is asked once at the end of the run whether to open them.

  • New `scripts/lib/pr_prompt.sh` helper:
    • `pr_prompt_extract_url ` — pulls the first `https://github.com/.../pull/N\` URL out of a blob
    • `pr_prompt_finalize <urls...>` — lists URLs and, if stdin/stdout are a TTY and `PR_PROMPT_SUPPRESS` is unset, prompts `Open PR(s) in browser now? [y/N]` and opens via `open` / `xdg-open` / `cmd.exe start`
    • Honors `PR_PROMPT_SUPPRESS=1` to disable the prompt entirely (used by parent drivers and CI)
  • Single-repo scripts (`bring_up_to_date.sh`, `cargo_update.sh`, `template_backport.sh`): drop their own `open_url` and call the helper instead. Run standalone, you get one prompt at the end.
  • `*_all` drivers (`bring_up_to_date_all.sh`, `cargo_update_all.sh`, `template_backport_all.sh`): `export PR_PROMPT_SUPPRESS=1` so children stay quiet, then harvest URLs from per-repo logs and call `pr_prompt_finalize` once at the very end. `bring_up_to_date_all` now `tee`s child output to per-repo log files (it previously dropped output straight to terminal) so URLs can be collected.
  • Non-interactive runs (CI, piped output) skip the prompt automatically and just print the URLs.

Test plan

  • `just cu --execute path/to/repo` prints PR URL and prompts once at end
  • `just cua --execute` runs across all downstream repos, lists every PR URL, prompts once
  • Replying `y` opens all collected URLs; replying anything else exits cleanly
  • `PR_PROMPT_SUPPRESS=1 just cua --execute` produces no prompt
  • Piping the script through `tee` does not hang waiting for input

Previously cargo_update.sh, bring_up_to_date.sh, and template_backport.sh
each opened the resulting PR URL in a browser tab automatically the
moment they finished. When run via the *_all drivers across many
downstream repos, this dumped a flurry of distracting tabs into the
foreground.

Add scripts/lib/pr_prompt.sh, a small shared helper that:
- extracts PR URLs from script output
- lists collected URLs at the end of a run
- only prompts to open them if stdin/stdout are a TTY and the new
  PR_PROMPT_SUPPRESS env var is unset

Wire all single-repo scripts to use the helper instead of auto-opening.
The *_all drivers export PR_PROMPT_SUPPRESS=1 around child invocations
(so children stay quiet), then collect URLs from per-repo logs and call
pr_prompt_finalize once at the very end. bring_up_to_date_all now tees
child output to per-repo log files so URLs can be harvested.
@sksizer
sksizer merged commit 600157a into main Apr 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant