Skip to content

Commit d2c5c84

Browse files
authored
fix(internal/postprocessor): include module and package in scope (#7294)
With this change the postprocessor includes the module in scopes for nested clients.
1 parent 19e9d03 commit d2c5c84

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

.github/.OwlBot.lock.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-go:latest
16-
digest: sha256:989e97271b91bb0bd869bd5d714d1ea076136090657aab7ba30635bfa1b38395
16+
digest: sha256:30a2b50c928425fceddf12f8e37a03fb7ca8cf0e63ee4b9807bed3dbfb79f323

internal/postprocessor/main.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,10 @@ func (c *config) getScopeFromGoogleapisCommitHash(commitHash string) (string, er
363363
for _, filePath := range files {
364364
for _, config := range generator.MicrogenGapicConfigs {
365365
if config.InputDirectoryPath == filepath.Dir(filePath) {
366-
scope := config.Pkg
366+
// trim prefix
367+
scope := strings.TrimPrefix(config.ImportPath, "cloud.google.com/go/")
368+
// trim version
369+
scope = filepath.Dir(scope)
367370
if _, value := scopesMap[scope]; !value {
368371
scopesMap[scope] = true
369372
scopes = append(scopes, scope)

internal/postprocessor/main_test.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestProcessCommit(t *testing.T) {
5959
wantErr bool
6060
}{
6161
{
62-
name: "first test",
62+
name: "test nested commits",
6363
title: "feat: [REPLACEME] Adds named reservation to InstancePolicy",
6464
body: `- [ ] Regenerate this pull request now.
6565
@@ -123,6 +123,27 @@ Source-Link: https://github.com/googleapis/googleapis-gen/commit/5b3d3a550015e
123123
Copy-Tag: eyJwIjoiamF2YS1iYXRjaC8uT3dsQm90LnlhbWwiLCJoIjoiNWIzZDNhNTUwMDE1ZTkzNjdhZDEzZWU1ZjlmZWJlMGMzZjg0Y2YzMyJ9
124124
END_NESTED_COMMIT`,
125125
},
126+
{
127+
name: "test nested client scope",
128+
title: "feat: [REPLACEME] added JSON_PACKAGE field to ExportAgentRequest",
129+
body: `- [ ] Regenerate this pull request now.
130+
131+
PiperOrigin-RevId: 504031208
132+
133+
Source-Link: https://github.com/googleapis/googleapis/commit/c6af392b613b435757358fac555628d84e443abd
134+
135+
Source-Link: googleapis/googleapis-gen@7849764
136+
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzg0OTc2NDc3NzYyZDk4YTljMzA4MzRkYzQ1ODVkODE1YWYyZmJmYiJ9`,
137+
want: "feat(dialogflow/cx): added JSON_PACKAGE field to ExportAgentRequest",
138+
want1: `- [ ] Regenerate this pull request now.
139+
140+
PiperOrigin-RevId: 504031208
141+
142+
Source-Link: https://github.com/googleapis/googleapis/commit/c6af392b613b435757358fac555628d84e443abd
143+
144+
Source-Link: googleapis/googleapis-gen@7849764
145+
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzg0OTc2NDc3NzYyZDk4YTljMzA4MzRkYzQ1ODVkODE1YWYyZmJmYiJ9`,
146+
},
126147
}
127148
for _, tt := range tests {
128149

0 commit comments

Comments
 (0)