Skip to content

Commit 0523329

Browse files
authored
feat: add context to Librarian PRs (#2698)
Fixes #2695
1 parent 7a3e404 commit 0523329

File tree

3 files changed

+56
-19
lines changed

3 files changed

+56
-19
lines changed

internal/librarian/generate_pull_request_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ func TestFormatGenerationPRBody(t *testing.T) {
116116
"another-library": "abcdefg",
117117
},
118118
failedLibraries: []string{},
119-
want: fmt.Sprintf(`BEGIN_COMMIT
119+
want: fmt.Sprintf(`PR created by the Librarian CLI to generate Cloud Client Libraries code from protos.
120+
121+
BEGIN_COMMIT
120122
121123
BEGIN_NESTED_COMMIT
122124
fix: a bug fix
@@ -208,7 +210,9 @@ Language Image: %s`,
208210
"another-library": "abcdefg",
209211
},
210212
failedLibraries: []string{},
211-
want: fmt.Sprintf(`BEGIN_COMMIT
213+
want: fmt.Sprintf(`PR created by the Librarian CLI to generate Cloud Client Libraries code from protos.
214+
215+
BEGIN_COMMIT
212216
213217
BEGIN_NESTED_COMMIT
214218
fix: a bug fix
@@ -297,7 +301,9 @@ Language Image: %s`,
297301
"failed-library-a",
298302
"failed-library-b",
299303
},
300-
want: fmt.Sprintf(`BEGIN_COMMIT
304+
want: fmt.Sprintf(`PR created by the Librarian CLI to generate Cloud Client Libraries code from protos.
305+
306+
BEGIN_COMMIT
301307
302308
BEGIN_NESTED_COMMIT
303309
fix: a bug fix
@@ -381,7 +387,9 @@ Language Image: %s
381387
"one-library": "1234567890",
382388
},
383389
failedLibraries: []string{},
384-
want: fmt.Sprintf(`BEGIN_COMMIT
390+
want: fmt.Sprintf(`PR created by the Librarian CLI to generate Cloud Client Libraries code from protos.
391+
392+
BEGIN_COMMIT
385393
386394
BEGIN_NESTED_COMMIT
387395
fix: a bug fix
@@ -600,7 +608,9 @@ func TestFormatOnboardPRBody(t *testing.T) {
600608
},
601609
api: "path/to",
602610
library: "one-library",
603-
want: fmt.Sprintf(`BEGIN_COMMIT
611+
want: fmt.Sprintf(`PR created by the Librarian CLI to onboard a new Cloud Client Library.
612+
613+
BEGIN_COMMIT
604614
605615
feat: onboard a new library
606616

internal/librarian/release_notes.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ var (
6464

6565
releaseNotesTemplate = template.Must(template.New("releaseNotes").Funcs(template.FuncMap{
6666
"shortSHA": shortSHA,
67-
}).Parse(`Librarian Version: {{.LibrarianVersion}}
67+
}).Parse(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
68+
69+
Librarian Version: {{.LibrarianVersion}}
6870
Language Image: {{.ImageVersion}}
6971
{{ $prInfo := . }}
7072
{{- range .NoteSections -}}
@@ -105,7 +107,9 @@ Language Image: {{.ImageVersion}}
105107

106108
genBodyTemplate = template.Must(template.New("genBody").Funcs(template.FuncMap{
107109
"shortSHA": shortSHA,
108-
}).Parse(`BEGIN_COMMIT
110+
}).Parse(`PR created by the Librarian CLI to generate Cloud Client Libraries code from protos.
111+
112+
BEGIN_COMMIT
109113
{{ range .Commits }}
110114
BEGIN_NESTED_COMMIT
111115
{{.Type}}: {{.Subject}}
@@ -136,7 +140,9 @@ Language Image: {{.ImageVersion}}
136140
{{- end }}
137141
`))
138142

139-
onboardingBodyTemplate = template.Must(template.New("onboardingBody").Parse(`BEGIN_COMMIT
143+
onboardingBodyTemplate = template.Must(template.New("onboardingBody").Parse(`PR created by the Librarian CLI to onboard a new Cloud Client Library.
144+
145+
BEGIN_COMMIT
140146
141147
feat: onboard a new library
142148

internal/librarian/release_notes_test.go

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ func TestFormatReleaseNotes(t *testing.T) {
7878
},
7979
},
8080
ghRepo: &github.Repository{Owner: "owner", Name: "repo"},
81-
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
81+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
82+
83+
Librarian Version: %s
8284
Language Image: go:1.21
8385
<details><summary>my-library: 1.1.0</summary>
8486
@@ -126,7 +128,9 @@ Language Image: go:1.21
126128
},
127129
},
128130
ghRepo: &github.Repository{Owner: "owner", Name: "repo"},
129-
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
131+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
132+
133+
Librarian Version: %s
130134
Language Image: go:1.21
131135
<details><summary>my-library: 1.1.0</summary>
132136
@@ -172,7 +176,9 @@ Language Image: go:1.21
172176
},
173177
},
174178
ghRepo: &github.Repository{Owner: "owner", Name: "repo"},
175-
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
179+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
180+
181+
Librarian Version: %s
176182
Language Image: go:1.21
177183
<details><summary>my-library: 1.1.0</summary>
178184
@@ -225,7 +231,9 @@ Language Image: go:1.21
225231
},
226232
},
227233
ghRepo: &github.Repository{Owner: "owner", Name: "repo"},
228-
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
234+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
235+
236+
Librarian Version: %s
229237
Language Image: go:1.21
230238
<details><summary>lib-a: 1.1.0</summary>
231239
@@ -278,7 +286,9 @@ Language Image: go:1.21
278286
},
279287
},
280288
ghRepo: &github.Repository{Owner: "owner", Name: "repo"},
281-
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
289+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
290+
291+
Librarian Version: %s
282292
Language Image: go:1.21
283293
<details><summary>my-library: 1.1.0</summary>
284294
@@ -315,7 +325,9 @@ Language Image: go:1.21
315325
},
316326
},
317327
ghRepo: &github.Repository{Owner: "owner", Name: "repo"},
318-
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
328+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
329+
330+
Librarian Version: %s
319331
Language Image: go:1.21
320332
<details><summary>my-library: 1.1.0</summary>
321333
@@ -334,8 +346,11 @@ Language Image: go:1.21
334346
Image: "go:1.21",
335347
Libraries: []*config.LibraryState{},
336348
},
337-
ghRepo: &github.Repository{},
338-
wantReleaseNote: fmt.Sprintf("Librarian Version: %s\nLanguage Image: go:1.21", librarianVersion),
349+
ghRepo: &github.Repository{},
350+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
351+
352+
Librarian Version: %s
353+
Language Image: go:1.21`, librarianVersion),
339354
},
340355
{
341356
name: "generate with chore",
@@ -361,7 +376,9 @@ Language Image: go:1.21
361376
},
362377
},
363378
ghRepo: &github.Repository{Owner: "owner", Name: "repo"},
364-
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
379+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
380+
381+
Librarian Version: %s
365382
Language Image: go:1.21
366383
<details><summary>my-library: 1.1.0</summary>
367384
@@ -419,7 +436,9 @@ Language Image: go:1.21
419436
},
420437
},
421438
ghRepo: &github.Repository{Owner: "owner", Name: "repo"},
422-
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
439+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
440+
441+
Librarian Version: %s
423442
Language Image: go:1.21
424443
<details><summary>j: 1.1.0</summary>
425444
@@ -678,7 +697,9 @@ Language Image: go:1.21
678697
},
679698
},
680699
ghRepo: &github.Repository{Owner: "owner", Name: "repo"},
681-
wantReleaseNote: fmt.Sprintf(`Librarian Version: %s
700+
wantReleaseNote: fmt.Sprintf(`PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release.
701+
702+
Librarian Version: %s
682703
Language Image: go:1.21
683704
<details><summary>j: 1.1.0</summary>
684705

0 commit comments

Comments
 (0)