Skip to content

Commit

Permalink
feat: sorts dependabot prs
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszmajsak committed Dec 5, 2019
1 parent cc29381 commit 3e920e1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/cmd/generate/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package generate

import (
"os"
"sort"
"strings"
"text/template"

Expand All @@ -24,6 +25,7 @@ func NewCmd() *cobra.Command {
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error { //nolint[:unparam]
pullRequests := fetchRelatedPRs(repo, from)
sortDependencyPRs(pullRequests)
t, err := template.New("changelog").Parse(Default)
if err != nil {
return err
Expand Down Expand Up @@ -61,3 +63,10 @@ func fetchRelatedPRs(repoName, ref string) map[string][]github.PullRequest {

return prsByLabels
}

func sortDependencyPRs(prsByLabels map[string][]github.PullRequest) {
dependencies := prsByLabels["dependencies"]
sort.SliceStable(dependencies, func(i, j int) bool {
return strings.Compare(dependencies[i].Title, dependencies[j].Title) < 0
})
}

0 comments on commit 3e920e1

Please sign in to comment.