Skip to content

Commit 6b27585

Browse files
committed
fully implement closed tags and also use #<int> for linking PR refs
1 parent dace80e commit 6b27585

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

internal/cmd/combine_prs.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ func CombinePRsWithStats(ctx context.Context, graphQlClient *api.GraphQLClient,
7171
}
7272
}
7373

74+
combinedPrNumbers := []string{}
7475
for _, pr := range opts.Pulls {
7576
if opts.Noop {
7677
Logger.Debug("Simulating merge of branch", "branch", pr.Head.Ref)
7778
combined = append(combined, fmt.Sprintf("#%d - %s", pr.Number, pr.Title))
79+
combinedPrNumbers = append(combinedPrNumbers, fmt.Sprintf("#%d", pr.Number))
7880
} else {
7981
err := mergeBranch(ctx, restClient, opts.Repo, workingBranchName, pr.Head.Ref)
8082
if err != nil {
@@ -87,6 +89,7 @@ func CombinePRsWithStats(ctx context.Context, graphQlClient *api.GraphQLClient,
8789
} else {
8890
Logger.Debug("Merged branch", "branch", pr.Head.Ref)
8991
combined = append(combined, fmt.Sprintf("#%d - %s", pr.Number, pr.Title))
92+
combinedPrNumbers = append(combinedPrNumbers, fmt.Sprintf("#%d", pr.Number))
9093
}
9194
}
9295
}
@@ -102,7 +105,7 @@ func CombinePRsWithStats(ctx context.Context, graphQlClient *api.GraphQLClient,
102105
Logger.Warn("Failed to delete working branch", "branch", workingBranchName, "error", err)
103106
}
104107

105-
prBody := generatePRBody(combined, mergeConflicts, opts.Command)
108+
prBody := generatePRBody(combinedPrNumbers, mergeConflicts, opts.Command)
106109
prTitle := "Combined PRs"
107110
prNumber, prErr := createPullRequestWithNumber(ctx, restClient, opts.Repo, prTitle, combineBranchName, repoDefaultBranch, prBody, addLabels, addAssignees)
108111
if prErr != nil {
@@ -200,12 +203,19 @@ func getBranchSHA(ctx context.Context, client RESTClientInterface, repo github.R
200203
return ref.Object.SHA, nil
201204
}
202205

203-
// Updated generatePRBody to include the command used
204-
func generatePRBody(combinedPRs, mergeFailedPRs []string, command string) string {
206+
// Updated generatePRBody to include the command used and handle PR autoclose logic
207+
// combinedPrNumbers looks like ["#1", "#2"]
208+
// mergeFailedPRs looks like ["#3", "#4"]
209+
func generatePRBody(combinedPrNumbers []string, mergeFailedPRs []string, command string) string {
205210
body := "✅ The following pull requests have been successfully combined:\n"
206-
for _, pr := range combinedPRs {
207-
body += "- " + pr + "\n"
211+
for _, prNumber := range combinedPrNumbers {
212+
prRef := prNumber
213+
if !noAutoclose {
214+
prRef = "closes: " + prNumber
215+
}
216+
body += "- " + prRef + "\n"
208217
}
218+
209219
if len(mergeFailedPRs) > 0 {
210220
body += "\n⚠️ The following pull requests could not be merged due to conflicts:\n"
211221
for _, pr := range mergeFailedPRs {

0 commit comments

Comments
 (0)