From 6853355d15983ef8718f00628ed02dde8214b399 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Tue, 3 Feb 2026 21:19:48 -0800 Subject: [PATCH 1/2] fix(submit): derive default PR title from first commit message The default PR title is now derived from the subject of the first commit in the branch (the oldest commit unique to the branch) instead of the branch name. Falls back to the branch-name-based title if no commits are available. --- cmd/submit.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/submit.go b/cmd/submit.go index c4c722d..5dba2ae 100644 --- a/cmd/submit.go +++ b/cmd/submit.go @@ -281,8 +281,8 @@ func createPRForBranch(g *git.Git, ghClient *github.Client, cfg *config.Config, // Determine if draft (not targeting trunk = middle of stack) draft := base != trunk - // Generate default title from branch name - defaultTitle := generateTitleFromBranch(branch) + // Generate default title from first commit message (falls back to branch name) + defaultTitle := generateDefaultTitle(g, base, branch) // Generate PR body from commits defaultBody, bodyErr := generatePRBody(g, base, branch) @@ -326,6 +326,18 @@ func createPRForBranch(g *git.Git, ghClient *github.Client, cfg *config.Config, return pr.Number, false, nil } +// generateDefaultTitle creates a PR title from the first commit message. +// Falls back to branch name if no commits are available. +func generateDefaultTitle(g *git.Git, base, branch string) string { + commits, err := g.GetCommits(base, branch) + if err != nil || len(commits) == 0 { + // Fall back to branch name + return generateTitleFromBranch(branch) + } + // Use the first commit's subject (oldest commit is last in array since GetCommits returns newest first) + return commits[len(commits)-1].Subject +} + // generateTitleFromBranch creates a PR title from a branch name. // Replaces - and _ with spaces and converts to title case. func generateTitleFromBranch(branch string) string { From fc4f2d600d7441d2150e736435e1ecf7d2433070 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Tue, 3 Feb 2026 21:43:57 -0800 Subject: [PATCH 2/2] fix(submit): trim whitespace and validate commit subject for PR title - Add whitespace trimming to handle commits with leading/trailing spaces - Fall back to branch name if subject is empty or whitespace-only - Improve comment to reference GetCommits ordering guarantee --- cmd/submit.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/submit.go b/cmd/submit.go index 5dba2ae..937789f 100644 --- a/cmd/submit.go +++ b/cmd/submit.go @@ -334,8 +334,17 @@ func generateDefaultTitle(g *git.Git, base, branch string) string { // Fall back to branch name return generateTitleFromBranch(branch) } - // Use the first commit's subject (oldest commit is last in array since GetCommits returns newest first) - return commits[len(commits)-1].Subject + // Use the first commit's subject. + // NOTE: GetCommits is defined to return commits in reverse chronological order (newest first), + // so the oldest commit in the range [base..branch] is the last element of the slice. + // See internal/git.GetCommits for the documented ordering guarantee. + // Trim whitespace to avoid malformed PR titles. + subject := strings.TrimSpace(commits[len(commits)-1].Subject) + if subject == "" { + // If the subject is empty or whitespace-only, fall back to branch name + return generateTitleFromBranch(branch) + } + return subject } // generateTitleFromBranch creates a PR title from a branch name.