Skip to content

Commit

Permalink
fix: defines dependabot prefix as regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszmajsak committed Apr 15, 2020
1 parent acc16e6 commit 75641c3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 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"
"regexp"
"sort"
"strings"
"text/template"
Expand Down Expand Up @@ -92,7 +93,7 @@ func shouldSkipInChangelog(labels []string) bool {
return false
}

const dependabotPrefix = "build(deps): bump "
var dependabotPrefix = regexp.MustCompile(`^build\(deps\): [B|b]ump `)

func simplifyDepsPRs(dependencies []github.PullRequest) []github.PullRequest {
sort.SliceStable(dependencies, func(i, j int) bool {
Expand All @@ -101,7 +102,8 @@ func simplifyDepsPRs(dependencies []github.PullRequest) []github.PullRequest {

latestDeps := make(map[string][]github.PullRequest)
for i := 0; i < len(dependencies); i++ {
prTitle := strings.Split(strings.TrimPrefix(dependencies[i].Title, dependabotPrefix), " ")
strippedPrefix := dependabotPrefix.ReplaceAllString(dependencies[i].Title, "")
prTitle := strings.Split(strippedPrefix, " ")
dep := prTitle[0]
version := prTitle[4]
dependencies[i].Title = dep + " to " + version
Expand Down

0 comments on commit 75641c3

Please sign in to comment.