Skip to content

Commit 77e1c8b

Browse files
committed
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.
1 parent efc2a3f commit 77e1c8b

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

cmd/submit.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ func createPRForBranch(g *git.Git, ghClient *github.Client, cfg *config.Config,
281281
// Determine if draft (not targeting trunk = middle of stack)
282282
draft := base != trunk
283283

284-
// Generate default title from branch name
285-
defaultTitle := generateTitleFromBranch(branch)
284+
// Generate default title from first commit message (falls back to branch name)
285+
defaultTitle := generateDefaultTitle(g, base, branch)
286286

287287
// Generate PR body from commits
288288
defaultBody, bodyErr := generatePRBody(g, base, branch)
@@ -326,6 +326,18 @@ func createPRForBranch(g *git.Git, ghClient *github.Client, cfg *config.Config,
326326
return pr.Number, false, nil
327327
}
328328

329+
// generateDefaultTitle creates a PR title from the first commit message.
330+
// Falls back to branch name if no commits are available.
331+
func generateDefaultTitle(g *git.Git, base, branch string) string {
332+
commits, err := g.GetCommits(base, branch)
333+
if err != nil || len(commits) == 0 {
334+
// Fall back to branch name
335+
return generateTitleFromBranch(branch)
336+
}
337+
// Use the first commit's subject (oldest commit is last in array since GetCommits returns newest first)
338+
return commits[len(commits)-1].Subject
339+
}
340+
329341
// generateTitleFromBranch creates a PR title from a branch name.
330342
// Replaces - and _ with spaces and converts to title case.
331343
func generateTitleFromBranch(branch string) string {

0 commit comments

Comments
 (0)