@@ -112,15 +112,24 @@ func runPush(cfg *config.Config, opts *pushOptions) error {
112112 // Create new PR — auto-generate title from commits/branch name,
113113 // then prompt interactively unless --auto or non-interactive.
114114 baseBranchForDiff := s .ActiveBaseBranch (b .Branch )
115- title := defaultPRTitle (baseBranchForDiff , b .Branch )
115+ title , commitBody := defaultPRTitleBody (baseBranchForDiff , b .Branch )
116+ originalTitle := title
116117 if ! opts .auto && cfg .IsInteractive () {
117118 p := prompter .New (cfg .In , cfg .Out , cfg .Err )
118119 input , err := p .Input (fmt .Sprintf ("Title for PR (branch %s):" , b .Branch ), title )
119120 if err == nil && input != "" {
120121 title = input
121122 }
122123 }
123- body := generatePRBody (s , b .Branch )
124+
125+ // If the user changed the title and the commit had a multi-line
126+ // message, put the full commit message in the PR body so no
127+ // content is lost.
128+ prBody := commitBody
129+ if title != originalTitle && commitBody != "" {
130+ prBody = originalTitle + "\n \n " + commitBody
131+ }
132+ body := generatePRBody (prBody )
124133
125134 newPR , createErr := client .CreatePR (baseBranch , b .Branch , title , body , opts .draft )
126135 if createErr != nil {
@@ -188,56 +197,33 @@ func runPush(cfg *config.Config, opts *pushOptions) error {
188197 return nil
189198}
190199
191- // defaultPRTitle generates a PR title from the branch's commits.
192- // If there is exactly one commit, use its subject. Otherwise, humanize the
193- // branch name (replace hyphens/underscores with spaces) .
194- func defaultPRTitle (base , head string ) string {
200+ // defaultPRTitleBody generates a PR title and body from the branch's commits.
201+ // If there is exactly one commit, use its subject as the title and its body
202+ // (if any) as the PR body. Otherwise, humanize the branch name for the title .
203+ func defaultPRTitleBody (base , head string ) ( string , string ) {
195204 commits , err := git .LogRange (base , head )
196205 if err == nil && len (commits ) == 1 {
197- return commits [0 ].Subject
206+ return commits [0 ].Subject , strings . TrimSpace ( commits [ 0 ]. Body )
198207 }
199- return humanize (head )
208+ return humanize (head ), ""
200209}
201210
202- // generatePRBody builds a rich PR description showing the downstack branches,
203- // the current branch, and a footer with links to the CLI and feedback form.
204- func generatePRBody (s * stack.Stack , currentBranch string ) string {
205- var lines []string
206-
207- // Current branch entry (always first)
208- lines = append (lines , fmt .Sprintf ("- `%s` ← *this PR*" , currentBranch ))
211+ // generatePRBody builds a PR description from the commit body (if any)
212+ // and a footer linking to the CLI and feedback form.
213+ func generatePRBody (commitBody string ) string {
214+ var parts []string
209215
210- // Walk downstack from just below current to the bottom, skipping merged branches
211- found := false
212- for i := len (s .Branches ) - 1 ; i >= 0 ; i -- {
213- b := s .Branches [i ]
214- if b .Branch == currentBranch {
215- found = true
216- continue
217- }
218- if ! found {
219- continue
220- }
221- if b .IsMerged () {
222- continue
223- }
224- if b .PullRequest != nil && b .PullRequest .URL != "" {
225- lines = append (lines , fmt .Sprintf ("- `%s` %s" , b .Branch , b .PullRequest .URL ))
226- } else {
227- lines = append (lines , fmt .Sprintf ("- `%s`" , b .Branch ))
228- }
216+ if commitBody != "" {
217+ parts = append (parts , commitBody )
229218 }
230219
231- // Trunk entry
232- lines = append (lines , fmt .Sprintf ("- `%s` (base)" , s .Trunk .Branch ))
233-
234- body := "---\n \n **Stacked Pull Requests**\n " + strings .Join (lines , "\n " )
235- body += fmt .Sprintf (
236- "\n \n <sub>Stack created with <a href=\" https://github.com/github/gh-stack\" >GitHub Stacks CLI</a> • <a href=\" %s\" >Give Feedback 💬</a></sub>" ,
220+ footer := fmt .Sprintf (
221+ "<sub>Stack created with <a href=\" https://github.com/github/gh-stack\" >GitHub Stacks CLI</a> • <a href=\" %s\" >Give Feedback 💬</a></sub>" ,
237222 feedbackBaseURL ,
238223 )
224+ parts = append (parts , footer )
239225
240- return body
226+ return strings . Join ( parts , " \n \n --- \n \n " )
241227}
242228
243229// humanize replaces hyphens and underscores with spaces.
0 commit comments