X Tutup
Skip to content

Commit feec114

Browse files
committed
Fix truncateLabels for empty values
1 parent 8d05448 commit feec114

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkg/cmd/issue/shared/display.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ func PrintIssues(io *iostreams.IOStreams, prefix string, totalCount int, issues
4949
}
5050

5151
func truncateLabels(w int, t string) string {
52+
if len(t) < 2 {
53+
return t
54+
}
5255
truncated := text.Truncate(w-2, t[1:len(t)-1])
5356
return fmt.Sprintf("(%s)", truncated)
5457
}

pkg/cmd/issue/shared/display_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ func Test_truncateLabels(t *testing.T) {
88
if got != expected {
99
t.Errorf("expected %q, got %q", expected, got)
1010
}
11+
12+
if truncateLabels(10, "") != "" {
13+
t.Error("blank value error")
14+
}
1115
}

0 commit comments

Comments
 (0)
X Tutup