Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pkg/github/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ import (
const (
releaseNoteBlock = "```release-note"
upstreamPRsBlock = "```upstream-prs"
commentTag = "<!--"
endBlock = "```"
)

var (
ignoreReleaseNoteFragments = []string{
"<!--",
"NONE",
}
)

// Get the text between startBlock and endBlock
func textBlockBetween(body, startBlock string) string {
// Use a bufio.Scanner to scan line by line because it handles both `\n` and `\r\n`.
Expand Down Expand Up @@ -133,7 +139,14 @@ func getUpstreamPRsV2(block string) []int {
func getReleaseNote(title, body string) string {
if strings.Contains(body, releaseNoteBlock) {
block := textBlockBetween(body, releaseNoteBlock)
if len(block) != 0 && !strings.Contains(block, commentTag) {
ignore := false
for _, commentTag := range ignoreReleaseNoteFragments {
if strings.Contains(block, commentTag) {
ignore = true
break
}
}
if !ignore && len(block) != 0 {
return block
}
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/github/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ func Test_getReleaseNote(t *testing.T) {
},
want: "Pineapple pizza",
},
{
name: "Ignore k8s style empty release note",
args: args{
title: "Ketchup on pizza",
body: "```release-note\r\nNONE\n",
},
want: "Ketchup on pizza",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we don't want ketchup on pizza!

},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading