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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ uv run pre-commit install
- `flow branch [name]` — create and check out a new branch (`<user>/<name>` 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
Expand Down
32 changes: 30 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func run(name string, args ...string) {
func main() {
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: flow <command> [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)
}

Expand All @@ -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":
Expand All @@ -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)
}
}
Expand Down Expand Up @@ -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")
Expand Down
Loading