Skip to content

Commit

Permalink
Merge pull request #3684 from npolshakova/fix-sig-label-map-replacement
Browse files Browse the repository at this point in the history
Add sig labels to markdown
  • Loading branch information
k8s-ci-robot authored Jul 18, 2024
2 parents 076b3d5 + eddbe0e commit dbda6e5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
9 changes: 9 additions & 0 deletions pkg/notes/maps/testdata/unit/maps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,12 @@ datafields:
- kubectl
- apiserver
name: "Modifying release note areas"
---
pr: 95000
releasenote:
text: "This test string has been modified"
datafields:
testcase:
property: "Markdown"
expected: "This test string has been modified (#95000, @arghya88) [SIG Instrumentation and Scheduling]"
name: "Modifying release note markdown"
9 changes: 7 additions & 2 deletions pkg/notes/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ func (g *Gatherer) ReleaseNoteFromCommit(result *Result) (*ReleaseNote, error) {
authorURL := pr.GetUser().GetHTMLURL()
prURL := pr.GetHTMLURL()
isFeature := hasString(labelsWithPrefix(pr, "kind"), "feature")
noteSuffix := prettifySIGList(labelsWithPrefix(pr, "sig"))
sigLabels := labelsWithPrefix(pr, "sig")
noteSuffix := prettifySIGList(sigLabels)

isDuplicateSIG := false
if len(labelsWithPrefix(pr, "sig")) > 1 {
Expand Down Expand Up @@ -515,7 +516,7 @@ func (g *Gatherer) ReleaseNoteFromCommit(result *Result) (*ReleaseNote, error) {
AuthorURL: authorURL,
PrURL: prURL,
PrNumber: pr.GetNumber(),
SIGs: labelsWithPrefix(pr, "sig"),
SIGs: sigLabels,
Kinds: labelsWithPrefix(pr, "kind"),
Areas: labelsWithPrefix(pr, "area"),
Feature: isFeature,
Expand Down Expand Up @@ -1224,6 +1225,10 @@ func (rn *ReleaseNote) ApplyMap(noteMap *ReleaseNotesMap, markdownLinks bool) er
markdown = fmt.Sprintf("%s ([#%d](%s), [@%s](%s))",
indented, rn.PrNumber, rn.PrURL, rn.Author, rn.AuthorURL)
}
// Add sig labels to markdown
if rn.SIGs != nil {
markdown = fmt.Sprintf("%s [%s]", markdown, prettifySIGList(rn.SIGs))
}
// Uppercase the first character of the markdown to make it look uniform
rn.Markdown = capitalizeString(markdown)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/notes/notes_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestNewProviderFromInitString(t *testing.T) {
func TestParseReleaseNotesMap(t *testing.T) {
maps, err := ParseReleaseNotesMap("maps/testdata/unit/maps.yaml")
require.Nil(t, err)
require.GreaterOrEqual(t, 5, len(*maps))
require.GreaterOrEqual(t, 6, len(*maps))

maps, err = ParseReleaseNotesMap("maps/testdata/fullmap.yaml")
require.Nil(t, err)
Expand All @@ -59,7 +59,7 @@ func TestGetMapsForPR(t *testing.T) {

maps, err := provider.GetMapsForPR(95000)
require.Nil(t, err)
require.GreaterOrEqual(t, 5, len(maps))
require.GreaterOrEqual(t, 6, len(maps))

maps, err = provider.GetMapsForPR(123)
require.Nil(t, err)
Expand Down
5 changes: 3 additions & 2 deletions pkg/notes/notes_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ func (g *Gatherer) buildReleaseNote(pair *commitPrPair) (*ReleaseNote, error) {
authorURL := pr.GetUser().GetHTMLURL()
prURL := pr.GetHTMLURL()
isFeature := hasString(labelsWithPrefix(pr, "kind"), "feature")
noteSuffix := prettifySIGList(labelsWithPrefix(pr, "sig"))
sigLabels := labelsWithPrefix(pr, "sig")
noteSuffix := prettifySIGList(sigLabels)

isDuplicateSIG := false
if len(labelsWithPrefix(pr, "sig")) > 1 {
Expand Down Expand Up @@ -204,7 +205,7 @@ func (g *Gatherer) buildReleaseNote(pair *commitPrPair) (*ReleaseNote, error) {
AuthorURL: authorURL,
PrURL: prURL,
PrNumber: pr.GetNumber(),
SIGs: labelsWithPrefix(pr, "sig"),
SIGs: sigLabels,
Kinds: labelsWithPrefix(pr, "kind"),
Areas: labelsWithPrefix(pr, "area"),
Feature: isFeature,
Expand Down

0 comments on commit dbda6e5

Please sign in to comment.