Skip to content

Commit 21922f3

Browse files
authored
feat: reorder generate PR body (#2312)
Fixes #2071
1 parent e7eb9dd commit 21922f3

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed

internal/librarian/release_notes.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,20 @@ Language Image: {{.ImageVersion}}
9090

9191
genBodyTemplate = template.Must(template.New("genBody").Funcs(template.FuncMap{
9292
"shortSHA": shortSHA,
93-
}).Parse(`This pull request is generated with proto changes between
93+
}).Parse(`BEGIN_COMMIT_OVERRIDE
94+
{{ range .Commits }}
95+
BEGIN_NESTED_COMMIT
96+
{{.Type}}: [{{.LibraryID}}] {{.Subject}}
97+
{{.Body}}
98+
99+
PiperOrigin-RevId: {{index .Footers "PiperOrigin-RevId"}}
100+
101+
Source-link: [googleapis/googleapis@{{shortSHA .CommitHash}}](https://github.com/googleapis/googleapis/commit/{{.CommitHash}})
102+
END_NESTED_COMMIT
103+
{{ end }}
104+
END_COMMIT_OVERRIDE
105+
106+
This pull request is generated with proto changes between
94107
[googleapis/googleapis@{{shortSHA .StartSHA}}](https://github.com/googleapis/googleapis/commit/{{.StartSHA}})
95108
(exclusive) and
96109
[googleapis/googleapis@{{shortSHA .EndSHA}}](https://github.com/googleapis/googleapis/commit/{{.EndSHA}})
@@ -106,19 +119,6 @@ Language Image: {{.ImageVersion}}
106119
- {{ . }}
107120
{{- end -}}
108121
{{- end }}
109-
110-
BEGIN_COMMIT_OVERRIDE
111-
{{ range .Commits }}
112-
BEGIN_NESTED_COMMIT
113-
{{.Type}}: [{{.LibraryID}}] {{.Subject}}
114-
{{.Body}}
115-
116-
PiperOrigin-RevId: {{index .Footers "PiperOrigin-RevId"}}
117-
118-
Source-link: [googleapis/googleapis@{{shortSHA .CommitHash}}](https://github.com/googleapis/googleapis/commit/{{.CommitHash}})
119-
END_NESTED_COMMIT
120-
{{ end }}
121-
END_COMMIT_OVERRIDE
122122
`))
123123
)
124124

internal/librarian/release_notes_test.go

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,7 @@ func TestFormatGenerationPRBody(t *testing.T) {
9999
"another-library": "abcdefg",
100100
},
101101
failedLibraries: []string{},
102-
want: fmt.Sprintf(`This pull request is generated with proto changes between
103-
[googleapis/googleapis@abcdef0](https://github.com/googleapis/googleapis/commit/abcdef0000000000000000000000000000000000)
104-
(exclusive) and
105-
[googleapis/googleapis@fedcba0](https://github.com/googleapis/googleapis/commit/fedcba0987654321000000000000000000000000)
106-
(inclusive).
107-
108-
Librarian Version: %s
109-
Language Image: %s
110-
111-
BEGIN_COMMIT_OVERRIDE
102+
want: fmt.Sprintf(`BEGIN_COMMIT_OVERRIDE
112103
113104
BEGIN_NESTED_COMMIT
114105
fix: [one-library] a bug fix
@@ -119,7 +110,16 @@ PiperOrigin-RevId: 573342
119110
Source-link: [googleapis/googleapis@fedcba0](https://github.com/googleapis/googleapis/commit/fedcba0987654321000000000000000000000000)
120111
END_NESTED_COMMIT
121112
122-
END_COMMIT_OVERRIDE`,
113+
END_COMMIT_OVERRIDE
114+
115+
This pull request is generated with proto changes between
116+
[googleapis/googleapis@abcdef0](https://github.com/googleapis/googleapis/commit/abcdef0000000000000000000000000000000000)
117+
(exclusive) and
118+
[googleapis/googleapis@fedcba0](https://github.com/googleapis/googleapis/commit/fedcba0987654321000000000000000000000000)
119+
(inclusive).
120+
121+
Librarian Version: %s
122+
Language Image: %s`,
123123
librarianVersion, "go:1.21"),
124124
},
125125
{
@@ -171,20 +171,7 @@ END_COMMIT_OVERRIDE`,
171171
"failed-library-a",
172172
"failed-library-b",
173173
},
174-
want: fmt.Sprintf(`This pull request is generated with proto changes between
175-
[googleapis/googleapis@abcdef0](https://github.com/googleapis/googleapis/commit/abcdef0000000000000000000000000000000000)
176-
(exclusive) and
177-
[googleapis/googleapis@fedcba0](https://github.com/googleapis/googleapis/commit/fedcba0987654321000000000000000000000000)
178-
(inclusive).
179-
180-
Librarian Version: %s
181-
Language Image: %s
182-
183-
## Generation failed for
184-
- failed-library-a
185-
- failed-library-b
186-
187-
BEGIN_COMMIT_OVERRIDE
174+
want: fmt.Sprintf(`BEGIN_COMMIT_OVERRIDE
188175
189176
BEGIN_NESTED_COMMIT
190177
fix: [one-library] a bug fix
@@ -195,7 +182,20 @@ PiperOrigin-RevId: 573342
195182
Source-link: [googleapis/googleapis@fedcba0](https://github.com/googleapis/googleapis/commit/fedcba0987654321000000000000000000000000)
196183
END_NESTED_COMMIT
197184
198-
END_COMMIT_OVERRIDE`,
185+
END_COMMIT_OVERRIDE
186+
187+
This pull request is generated with proto changes between
188+
[googleapis/googleapis@abcdef0](https://github.com/googleapis/googleapis/commit/abcdef0000000000000000000000000000000000)
189+
(exclusive) and
190+
[googleapis/googleapis@fedcba0](https://github.com/googleapis/googleapis/commit/fedcba0987654321000000000000000000000000)
191+
(inclusive).
192+
193+
Librarian Version: %s
194+
Language Image: %s
195+
196+
## Generation failed for
197+
- failed-library-a
198+
- failed-library-b`,
199199
librarianVersion, "go:1.21"),
200200
},
201201
{
@@ -244,16 +244,7 @@ END_COMMIT_OVERRIDE`,
244244
"one-library": "1234567890",
245245
},
246246
failedLibraries: []string{},
247-
want: fmt.Sprintf(`This pull request is generated with proto changes between
248-
[googleapis/googleapis@1234567](https://github.com/googleapis/googleapis/commit/1234567890000000000000000000000000000000)
249-
(exclusive) and
250-
[googleapis/googleapis@fedcba0](https://github.com/googleapis/googleapis/commit/fedcba0987654321000000000000000000000000)
251-
(inclusive).
252-
253-
Librarian Version: %s
254-
Language Image: %s
255-
256-
BEGIN_COMMIT_OVERRIDE
247+
want: fmt.Sprintf(`BEGIN_COMMIT_OVERRIDE
257248
258249
BEGIN_NESTED_COMMIT
259250
fix: [one-library] a bug fix
@@ -273,7 +264,16 @@ PiperOrigin-RevId: 98765
273264
Source-link: [googleapis/googleapis@1234567](https://github.com/googleapis/googleapis/commit/1234567890abcdef000000000000000000000000)
274265
END_NESTED_COMMIT
275266
276-
END_COMMIT_OVERRIDE`,
267+
END_COMMIT_OVERRIDE
268+
269+
This pull request is generated with proto changes between
270+
[googleapis/googleapis@1234567](https://github.com/googleapis/googleapis/commit/1234567890000000000000000000000000000000)
271+
(exclusive) and
272+
[googleapis/googleapis@fedcba0](https://github.com/googleapis/googleapis/commit/fedcba0987654321000000000000000000000000)
273+
(inclusive).
274+
275+
Librarian Version: %s
276+
Language Image: %s`,
277277
librarianVersion, "go:1.21"),
278278
},
279279
{

0 commit comments

Comments
 (0)