Skip to content

Commit b25be45

Browse files
authored
feat(stategen): populate release_exclude_paths for snippets (googleapis#12942)
This should simplify the first release after migration. Additionally, we only conditionally mention snippets at all, which simplifies handwritten/core migration. Fixes googleapis/librarian#2335
1 parent f95fef9 commit b25be45

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

internal/stategen/main.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ func addModule(repoRoot string, ppc *postProcessorConfig, state *LibrarianState,
124124
LastGeneratedCommit: googleapisCommit,
125125
SourceRoots: []string{
126126
moduleName,
127-
"internal/generated/snippets/" + moduleName,
128-
},
129-
RemoveRegex: []string{
130-
"^internal/generated/snippets/" + moduleName + "/",
131127
},
132128
TagFormat: "{id}/v{version}",
133129
}
@@ -140,6 +136,15 @@ func addModule(repoRoot string, ppc *postProcessorConfig, state *LibrarianState,
140136

141137
addAPIProtoPaths(ppc, moduleName, library)
142138

139+
if len(library.APIs) > 0 {
140+
library.SourceRoots = append(library.SourceRoots, "internal/generated/snippets/"+moduleName)
141+
library.RemoveRegex = append(library.RemoveRegex, "^internal/generated/snippets/"+moduleName+"/")
142+
// Probably irrelevant after the first release, but changes within the snippets aren't release-relevant;
143+
// for the first release after onboarding, we will see an OwlBot commit updating snippet metadata with the
144+
// final release-please-based commit, and we don't want to use that.
145+
library.ReleaseExcludePaths = append(library.ReleaseExcludePaths, "internal/generated/snippets/"+moduleName+"/")
146+
}
147+
143148
if err := addGeneratedCodeRemovals(repoRoot, moduleRoot, library); err != nil {
144149
return err
145150
}

0 commit comments

Comments
 (0)