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

Check failure on line 367 in main.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected <<, expected }

Check failure on line 367 in main.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: unexpected <<, expected }
if copyLabelsString == "" {
return []string{}
}
// remove empty strings from final list, eg: "foo,,bar" -> ["foo" "bar"]:
return strings.FieldsFunc(copyLabelsString, func(c rune) bool {

Check failure on line 372 in main.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected {, expected (

Check failure on line 372 in main.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: unexpected {, expected (
return c == ','

Check failure on line 373 in main.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected return, expected )

Check failure on line 373 in main.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: unexpected return, expected )
})
||||||| parent of 36790c1 (handle empty strings in copy-labels list)

Check failure on line 375 in main.go

View workflow job for this annotation

GitHub Actions / test

syntax error: non-declaration statement outside function body

Check failure on line 375 in main.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: non-declaration statement outside function body
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 {

Check failure on line 382 in main.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected {, expected (

Check failure on line 382 in main.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: unexpected {, expected (
return c == ','

Check failure on line 383 in main.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected return, expected )

Check failure on line 383 in main.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: unexpected return, expected )
})
>>>>>>> 36790c1 (handle empty strings in copy-labels list)

Check failure on line 385 in main.go

View workflow job for this annotation

GitHub Actions / test

syntax error: non-declaration statement outside function body

Check failure on line 385 in main.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: non-declaration statement outside function body
}
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.