Skip to content

Commit 973d2df

Browse files
authored
fix: add cl num in release note (#2156)
Fixes #2112
1 parent 1503540 commit 973d2df

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

internal/librarian/release_notes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ Language Image: {{.ImageVersion}}
7575
{{ range .CommitSections }}
7676
### {{.Heading}}
7777
{{ range .Commits }}
78+
{{ if index .Footers "PiperOrigin-RevId" -}}
79+
* {{.Subject}} (PiperOrigin-RevId: {{index .Footers "PiperOrigin-RevId"}}) ([{{shortSHA .SHA}}]({{"https://github.com/"}}{{$noteSection.RepoOwner}}/{{$noteSection.RepoName}}/commit/{{.SHA}}))
80+
{{- else -}}
7881
* {{.Subject}} ([{{shortSHA .SHA}}]({{"https://github.com/"}}{{$noteSection.RepoOwner}}/{{$noteSection.RepoName}}/commit/{{.SHA}}))
82+
{{- end }}
7983
{{ end }}
8084
8185
{{- end }}

internal/librarian/release_notes_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,58 @@ Language Image: go:1.21
536536
537537
* a bug fix ([fedcba0](https://github.com/owner/repo/commit/fedcba0987654321000000000000000000000000))
538538
539+
</details>`,
540+
librarianVersion, today),
541+
},
542+
{
543+
name: "single library release, with cl num",
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+
Subject: "new feature",
556+
SHA: hash1.String(),
557+
Footers: map[string]string{
558+
"PiperOrigin-RevId": "123456",
559+
},
560+
},
561+
{
562+
Type: "fix",
563+
Subject: "a bug fix",
564+
SHA: hash2.String(),
565+
Footers: map[string]string{
566+
"PiperOrigin-RevId": "987654",
567+
},
568+
},
569+
},
570+
ReleaseTriggered: true,
571+
},
572+
},
573+
},
574+
repo: &MockRepository{
575+
RemotesValue: []*git.Remote{git.NewRemote(nil, &gitconfig.RemoteConfig{Name: "origin", URLs: []string{"https://github.com/owner/repo.git"}})},
576+
},
577+
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
578+
Language Image: go:1.21
579+
<details><summary>my-library: 1.1.0</summary>
580+
581+
## [1.1.0](https://github.com/owner/repo/compare/my-library-1.0.0...my-library-1.1.0) (%s)
582+
583+
### Features
584+
585+
* new feature (PiperOrigin-RevId: 123456) ([1234567](https://github.com/owner/repo/commit/1234567890abcdef000000000000000000000000))
586+
587+
### Bug Fixes
588+
589+
* a bug fix (PiperOrigin-RevId: 987654) ([fedcba0](https://github.com/owner/repo/commit/fedcba0987654321000000000000000000000000))
590+
539591
</details>`,
540592
librarianVersion, today),
541593
},

0 commit comments

Comments
 (0)