Some cleanup
This commit is contained in:
parent
d3386d4a58
commit
4f44943d90
7 changed files with 90 additions and 19 deletions
|
|
@ -33,22 +33,39 @@ 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}}
|
||||
var prtmpl = template.Must(template.New("pr").Parse(`- Title: {{.Title}}
|
||||
Body: {{.Body}}
|
||||
`))
|
||||
|
||||
|
||||
// String returns a formatted string representation of the PullRequest
|
||||
func (pr PullRequest) String() string {
|
||||
var buf bytes.Buffer
|
||||
err := tmpl.Execute(&buf, pr)
|
||||
err := prtmpl.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) {
|
||||
type PRMap map[string][]PullRequest
|
||||
|
||||
var prlisttmpl = template.Must(template.New("prlist").Parse(`{{range $k, $v := .}}
|
||||
{{$k}}:
|
||||
{{$v}}
|
||||
{{end}}`))
|
||||
|
||||
func (p PRMap) String() string {
|
||||
var buf bytes.Buffer
|
||||
err := prlisttmpl.Execute(&buf, p)
|
||||
if err != nil {
|
||||
return "" // Return empty string on error
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func GetPRs(org, username string, from string, to string) (PRMap, error) {
|
||||
req, err := http.NewRequest(
|
||||
http.MethodGet,
|
||||
fmt.Sprintf(
|
||||
|
|
@ -81,7 +98,7 @@ func GetPRs(org, username string, from string, to string) (map[string][]PullRequ
|
|||
return nil, fmt.Errorf("error decoding response: %w", err)
|
||||
}
|
||||
|
||||
allthings := map[string][]PullRequest{}
|
||||
allthings := PRMap{}
|
||||
|
||||
for _, pr := range r.Items {
|
||||
reponameparts := strings.Split(pr.RepositoryUrl, "/")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue