feat: extract PR rendering to String() method using text/template
Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat>
This commit is contained in:
parent
9a71cf44bc
commit
d3386d4a58
2 changed files with 17 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue