Skip to content

Commit 3f24825

Browse files
authored
fix(internal/librarian): remove default specification_format in tidy (#3876)
The tidy command now removes `specification_format: protobuf` from librarian.yaml since "protobuf" is the default value.
1 parent 0cbbeef commit 3f24825

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

internal/librarian/tidy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ func tidyLibrary(cfg *config.Config, lib *config.Library) error {
7676
if len(lib.Roots) == 1 && lib.Roots[0] == "googleapis" {
7777
lib.Roots = nil
7878
}
79+
if lib.SpecificationFormat == "protobuf" {
80+
lib.SpecificationFormat = ""
81+
}
7982
// Only remove derivable API paths when there's exactly one API.
8083
// When there are multiple APIs, preserve all of them.
8184
if len(lib.APIs) == 1 && isDerivableAPIPath(cfg.Language, lib.Name, lib.APIs[0].Path) {

internal/librarian/tidy_test.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,21 @@ func TestTidy_DerivableFields(t *testing.T) {
211211
},
212212
}
213213
for _, test := range []struct {
214-
name string
215-
config *config.Config
216-
wantPath string
217-
wantNumLibs int
218-
wantNumChnls int
214+
name string
215+
config *config.Config
216+
wantPath string
217+
wantNumLibs int
218+
wantNumChnls int
219+
wantSpecificationFormat string
219220
}{
220221
{
221222
name: "derivable fields removed",
222223
config: &config.Config{
223224
Sources: googleapisSource,
224225
Libraries: []*config.Library{
225226
{
226-
Name: "google-cloud-accessapproval-v1",
227+
Name: "google-cloud-accessapproval-v1",
228+
SpecificationFormat: "protobuf",
227229
APIs: []*config.API{
228230
{
229231
Path: "google/cloud/accessapproval/v1",
@@ -232,9 +234,10 @@ func TestTidy_DerivableFields(t *testing.T) {
232234
},
233235
},
234236
},
235-
wantPath: "",
236-
wantNumLibs: 1,
237-
wantNumChnls: 0,
237+
wantPath: "",
238+
wantNumLibs: 1,
239+
wantNumChnls: 0,
240+
wantSpecificationFormat: "",
238241
},
239242
{
240243
name: "non-derivable path not removed",
@@ -299,6 +302,9 @@ func TestTidy_DerivableFields(t *testing.T) {
299302
t.Errorf("path should be %s, got %q", test.wantPath, ch.Path)
300303
}
301304
}
305+
if lib.SpecificationFormat != test.wantSpecificationFormat {
306+
t.Errorf("specification_format = %q, want %q", lib.SpecificationFormat, test.wantSpecificationFormat)
307+
}
302308
})
303309
}
304310
}

0 commit comments

Comments
 (0)