File tree 2 files changed +21
-17
lines changed
2 files changed +21
-17
lines changed Original file line number Diff line number Diff line change @@ -34,22 +34,8 @@ func NewCmd() *cobra.Command {
34
34
dependencies = simplifyDepsPRs (dependencies )
35
35
36
36
t , err := template .New ("changelog" ).Funcs (map [string ]interface {}{
37
- "withLabels" : func (prs []github.PullRequest , labels ... string ) []github.PullRequest {
38
- prsWithLabel := make ([]github.PullRequest , 0 )
39
- for i := range prs {
40
- pr := & prs [i ]
41
- if Contains (pr .Labels , labels ... ) {
42
- prsWithLabel = append (prsWithLabel , * pr )
43
- }
44
- }
45
- return prsWithLabel
46
- },
47
- "combine" : func (prs []github.PullRequest , title string ) ChangeGroup {
48
- return ChangeGroup {
49
- Title : title ,
50
- PullRequests : prs ,
51
- }
52
- },
37
+ "withLabels" : PullRequestWithLabels ,
38
+ "combine" : CombineToChangeGroup ,
53
39
}).Parse (formats ["changelog." + format ])
54
40
if err != nil {
55
41
return err
Original file line number Diff line number Diff line change @@ -13,7 +13,25 @@ type ChangeGroup struct {
13
13
PullRequests []github.PullRequest
14
14
}
15
15
16
- // TODO withLabels moved here
16
+ // PullRequestWithLabels filters slice of PRs to those matching one of the labels specified
17
+ func PullRequestWithLabels (prs []github.PullRequest , labels ... string ) []github.PullRequest {
18
+ prsWithLabel := make ([]github.PullRequest , 0 )
19
+ for i := range prs {
20
+ pr := & prs [i ]
21
+ if Contains (pr .Labels , labels ... ) {
22
+ prsWithLabel = append (prsWithLabel , * pr )
23
+ }
24
+ }
25
+ return prsWithLabel
26
+ }
27
+
28
+ // CombineToChangeGroup merges group of PRs with corresponding title
29
+ func CombineToChangeGroup (prs []github.PullRequest , title string ) ChangeGroup {
30
+ return ChangeGroup {
31
+ Title : title ,
32
+ PullRequests : prs ,
33
+ }
34
+ }
17
35
18
36
func Contains (s []string , es ... string ) bool {
19
37
for _ , e := range es {
You can’t perform that action at this time.
0 commit comments