Skip to content

Commit e536c9a

Browse files
authored
fix: format release note correctly for multiple same category commits (#1965)
Created release pull request in #1966 Fixes #1957
1 parent a00e91b commit e536c9a

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

internal/librarian/release_notes.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,12 @@ Language Image: {{.ImageVersion}}
7272
<details><summary>{{.LibraryID}}: {{.NewVersion}}</summary>
7373
7474
## [{{.NewVersion}}]({{"https://github.com/"}}{{.RepoOwner}}/{{.RepoName}}/compare/{{.PreviousTag}}...{{.NewTag}}) ({{.Date}})
75-
{{- range .CommitSections -}}
76-
{{- if .Commits -}}
77-
{{- if .Heading }}
78-
75+
{{ range .CommitSections }}
7976
### {{.Heading}}
80-
{{ end }}
81-
{{- range .Commits -}}
77+
{{ range .Commits }}
8278
* {{.Description}} ([{{shortSHA .SHA}}]({{"https://github.com/"}}{{$noteSection.RepoOwner}}/{{$noteSection.RepoName}}/commit/{{.SHA}}))
83-
{{- end }}
84-
{{- end }}
79+
{{ end }}
80+
8581
{{- end }}
8682
</details>
8783

internal/librarian/release_notes_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,57 @@ Language Image: go:1.21
529529
## [1.1.0](https://github.com/owner/repo/compare/my-library-1.0.0...my-library-1.1.0) (%s)
530530
531531
### Features
532+
532533
* new feature ([1234567](https://github.com/owner/repo/commit/1234567890abcdef000000000000000000000000))
533534
534535
### Bug Fixes
536+
535537
* a bug fix ([fedcba0](https://github.com/owner/repo/commit/fedcba0987654321000000000000000000000000))
538+
539+
</details>`,
540+
librarianVersion, today),
541+
},
542+
{
543+
name: "single library with multiple features",
544+
state: &config.LibrarianState{
545+
Image: "go:1.21",
546+
Libraries: []*config.LibraryState{
547+
{
548+
ID: "my-library",
549+
// this is the NewVersion in the release note.
550+
Version: "1.1.0",
551+
PreviousVersion: "1.0.0",
552+
Changes: []*conventionalcommits.ConventionalCommit{
553+
{
554+
Type: "feat",
555+
Description: "new feature",
556+
SHA: hash1.String(),
557+
},
558+
{
559+
Type: "feat",
560+
Description: "another new feature",
561+
SHA: hash2.String(),
562+
},
563+
},
564+
ReleaseTriggered: true,
565+
},
566+
},
567+
},
568+
repo: &MockRepository{
569+
RemotesValue: []*git.Remote{git.NewRemote(nil, &gitconfig.RemoteConfig{Name: "origin", URLs: []string{"https://github.com/owner/repo.git"}})},
570+
},
571+
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
572+
Language Image: go:1.21
573+
<details><summary>my-library: 1.1.0</summary>
574+
575+
## [1.1.0](https://github.com/owner/repo/compare/my-library-1.0.0...my-library-1.1.0) (%s)
576+
577+
### Features
578+
579+
* new feature ([1234567](https://github.com/owner/repo/commit/1234567890abcdef000000000000000000000000))
580+
581+
* another new feature ([fedcba0](https://github.com/owner/repo/commit/fedcba0987654321000000000000000000000000))
582+
536583
</details>`,
537584
librarianVersion, today),
538585
},
@@ -581,7 +628,9 @@ Language Image: go:1.21
581628
## [1.1.0](https://github.com/owner/repo/compare/lib-a-1.0.0...lib-a-1.1.0) (%s)
582629
583630
### Features
631+
584632
* feature for a ([1234567](https://github.com/owner/repo/commit/1234567890abcdef000000000000000000000000))
633+
585634
</details>
586635
587636
@@ -590,7 +639,9 @@ Language Image: go:1.21
590639
## [2.0.1](https://github.com/owner/repo/compare/lib-b-2.0.0...lib-b-2.0.1) (%s)
591640
592641
### Bug Fixes
642+
593643
* fix for b ([fedcba0](https://github.com/owner/repo/commit/fedcba0987654321000000000000000000000000))
644+
594645
</details>`,
595646
librarianVersion, today, today),
596647
},
@@ -630,7 +681,9 @@ Language Image: go:1.21
630681
## [1.1.0](https://github.com/owner/repo/compare/my-library-1.0.0...my-library-1.1.0) (%s)
631682
632683
### Features
684+
633685
* new feature ([1234567](https://github.com/owner/repo/commit/1234567890abcdef000000000000000000000000))
686+
634687
</details>`,
635688
librarianVersion, today),
636689
},

0 commit comments

Comments
 (0)