From c916b72197715ee89748f86f9e93eabd1978afc7 Mon Sep 17 00:00:00 2001 From: Patrick Linehan Date: Wed, 10 Jun 2026 16:55:06 -0700 Subject: [PATCH] add update command to sync PR title and body from HEAD commit Co-Authored-By: Claude Opus 4.8 --- README.md | 1 + main.go | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 348d568..6862fd3 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ uv run pre-commit install - `flow branch [name]` — create and check out a new branch (`/` or a random slug) - `flow create [-v]` — push the current branch and open a PR (`-v` opens it in the browser) - `flow view` — open the current branch's PR in the browser +- `flow update` — update the current branch's PR title and description from the HEAD commit message - `flow merge` — auto-squash-merge the current branch's PR, then return to the default (e.g. `main`) branch - `flow rebase` — rebase the current branch onto the latest default branch diff --git a/main.go b/main.go index 38058ff..2ba353e 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ func run(name string, args ...string) { func main() { if len(os.Args) < 2 { fmt.Fprintf(os.Stderr, "usage: flow [args]\n") - fmt.Fprintf(os.Stderr, "commands: branch, create, view, merge, clean, rebase, push, dirty\n") + fmt.Fprintf(os.Stderr, "commands: branch, create, view, update, merge, clean, rebase, push, dirty\n") os.Exit(2) } @@ -41,6 +41,8 @@ func main() { cmdCreate(os.Args[2:]) case "view": cmdView(os.Args[2:]) + case "update": + cmdUpdate(os.Args[2:]) case "merge": cmdMerge(os.Args[2:]) case "clean": @@ -53,7 +55,7 @@ func main() { cmdDirty(os.Args[2:]) default: fmt.Fprintf(os.Stderr, "flow: unknown command %q\n", os.Args[1]) - fmt.Fprintf(os.Stderr, "commands: branch, create, view, merge, clean, rebase, push, dirty\n") + fmt.Fprintf(os.Stderr, "commands: branch, create, view, update, merge, clean, rebase, push, dirty\n") os.Exit(2) } } @@ -182,6 +184,32 @@ func cmdView(args []string) { run("gh", "pr", "view", "--web", branch) } +func cmdUpdate(args []string) { + if len(args) > 0 { + fmt.Fprintf(os.Stderr, "usage: flow update\n") + os.Exit(2) + } + + branch, err := currentBranch() + if err != nil { + fmt.Fprintf(os.Stderr, "flow: %v\n", err) + os.Exit(1) + } + + if err := assertNotDefaultBranch(branch); err != nil { + fmt.Fprintf(os.Stderr, "flow: %v\n", err) + os.Exit(1) + } + + title, body, err := commitTitleBody(branch) + if err != nil { + fmt.Fprintf(os.Stderr, "flow: %v\n", err) + os.Exit(1) + } + + run("gh", "pr", "edit", branch, "--title", title, "--body", body) +} + func cmdMerge(args []string) { if len(args) > 0 { fmt.Fprintf(os.Stderr, "usage: flow merge\n")