From d3386d4a58533d3330704d1184dbe33740b213d8 Mon Sep 17 00:00:00 2001 From: Olivier Tremblay Date: Tue, 25 Nov 2025 12:46:54 -0500 Subject: [PATCH] feat: extract PR rendering to String() method using text/template Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) --- cmd/acb/summarize.go | 3 +-- contributions/gh.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/acb/summarize.go b/cmd/acb/summarize.go index d855718..e1b51fc 100644 --- a/cmd/acb/summarize.go +++ b/cmd/acb/summarize.go @@ -165,8 +165,7 @@ func buildPrompt(employeename string, prs map[string][]contributions.PullRequest for repo, prList := range prs { fullPrompt += fmt.Sprintf("Repository: %s\n", repo) for _, pr := range prList { - fullPrompt += fmt.Sprintf("- Title: %s\n", pr.Title) - fullPrompt += fmt.Sprintf(" Body: %s\n", pr.Body) + fullPrompt += pr.String() } } fullPrompt += "Issues:\n" diff --git a/contributions/gh.go b/contributions/gh.go index 80e3bd3..caaf2a3 100644 --- a/contributions/gh.go +++ b/contributions/gh.go @@ -8,6 +8,7 @@ import ( "net/http" "os" "strings" + "text/template" ) var ghc = http.Client{} @@ -32,6 +33,21 @@ type PullRequest struct { URL string } +// String returns a formatted string representation of the PullRequest +func (pr PullRequest) String() string { + tmpl := template.Must(template.New("pr").Parse(`- Title: {{.Title}} + Body: {{.Body}} +`)) + + var buf bytes.Buffer + err := tmpl.Execute(&buf, pr) + if err != nil { + return "" // Return empty string on error + } + + return buf.String() +} + func GetPRs(org, username string, from string, to string) (map[string][]PullRequest, error) { req, err := http.NewRequest( http.MethodGet,