Skip to content

Commit

Permalink
handle empty strings in copy-labels list
Browse files Browse the repository at this point in the history
  • Loading branch information
joemiller committed May 21, 2024
1 parent e5f1e2f commit 3f18f38
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,23 @@ func parseCopyLabels(copyLabelsString string) []string {
if copyLabelsString == "*" {
return []string{"*"}
}
<<<<<<< HEAD
if copyLabelsString == "" {
return []string{}
}
// remove empty strings from final list, eg: "foo,,bar" -> ["foo" "bar"]:
return strings.FieldsFunc(copyLabelsString, func(c rune) bool {
return c == ','
})
||||||| parent of 36790c1 (handle empty strings in copy-labels list)
if copyLabelsString == "" {
return []string{}
}
return strings.Split(copyLabelsString, ",")
=======
// remove empty strings from final list, eg: "foo,,bar" -> ["foo" "bar"]:
return strings.FieldsFunc(copyLabelsString, func(c rune) bool {
return c == ','
})
>>>>>>> 36790c1 (handle empty strings in copy-labels list)
}
9 changes: 9 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,20 @@ func Test_parseCopyLabels(t *testing.T) {
copyLabelsString: "",
want: []string{},
},
<<<<<<< HEAD
{
name: "empty values in list",
copyLabelsString: "foo,,bar",
want: []string{"foo", "bar"},
},
||||||| parent of 36790c1 (handle empty strings in copy-labels list)
=======
{
name: "empty values in list are removed",
copyLabelsString: "foo,,bar",
want: []string{"foo", "bar"},
},
>>>>>>> 36790c1 (handle empty strings in copy-labels list)
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 3f18f38

Please sign in to comment.