Skip to content

Commit 70317d7

Browse files
authored
chore(tool/cmd/migrate): do not block release in config.yaml (#4647)
Do not set `ReleaseBlocked` for libraries in config.yaml because we still rely on legacylibrarian to release the libraries. For #3618
1 parent 5b2f035 commit 70317d7

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

tool/cmd/migrate/legacylibrarian.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func runLibrarianMigration(ctx context.Context, language string, repoPath string
109109
if err := librarian.RunTidyOnConfig(ctx, repoPath, cfg); err != nil {
110110
return errTidyFailed
111111
}
112-
if err := blockLegacyGenerationAndRelease(repoPath, cfg); err != nil {
112+
if err := blockLegacyGeneration(repoPath, cfg); err != nil {
113113
return err
114114
}
115115
return nil
@@ -204,12 +204,11 @@ func buildConfigFromLibrarian(ctx context.Context, input *MigrationInput) (*conf
204204
return cfg, nil
205205
}
206206

207-
// blockLegacyGenerationAndRelease ensures that all libraries in the librarian
208-
// config have generation and release blocked in the legacy config, by rewriting
209-
// .librarian/config.yaml. This was previously a file maintained by hand, so a
210-
// comment line is added at the start. This function assumes that the current
211-
// directory is the repository root.
212-
func blockLegacyGenerationAndRelease(repoPath string, cfg *config.Config) error {
207+
// blockLegacyGeneration ensures that all libraries in the librarian config have generation blocked in the legacy
208+
// config, by rewriting .librarian/config.yaml.
209+
// This was previously a file maintained by hand, so a comment line is added at the start. This function assumes that
210+
// the current directory is the repository root.
211+
func blockLegacyGeneration(repoPath string, cfg *config.Config) error {
213212
legacyConfig, err := readLegacyConfig(repoPath)
214213
if err != nil {
215214
return err
@@ -223,7 +222,6 @@ func blockLegacyGenerationAndRelease(repoPath string, cfg *config.Config) error
223222
legacyConfig.Libraries = append(legacyConfig.Libraries, legacyLib)
224223
}
225224
legacyLib.GenerateBlocked = true
226-
legacyLib.ReleaseBlocked = true
227225
}
228226
configYaml, err := yaml.Marshal(legacyConfig)
229227
if err != nil {

tool/cmd/migrate/legacylibrarian_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ func TestToAPIs(t *testing.T) {
11601160
}
11611161
}
11621162

1163-
func TestBlockLegacyGenerationAndRelease(t *testing.T) {
1163+
func TestBlockLegacyGeneration(t *testing.T) {
11641164
tempDir := t.TempDir()
11651165
if err := os.Mkdir(filepath.Join(tempDir, librarianDir), 0755); err != nil {
11661166
t.Fatal(err)
@@ -1196,7 +1196,7 @@ func TestBlockLegacyGenerationAndRelease(t *testing.T) {
11961196
{Name: "migrated"},
11971197
},
11981198
}
1199-
if err := blockLegacyGenerationAndRelease(tempDir, migratedConfig); err != nil {
1199+
if err := blockLegacyGeneration(tempDir, migratedConfig); err != nil {
12001200
t.Fatal(err)
12011201
}
12021202
wantConfig := &legacyconfig.LibrarianConfig{
@@ -1212,18 +1212,15 @@ func TestBlockLegacyGenerationAndRelease(t *testing.T) {
12121212
{
12131213
LibraryID: "migrated-already-generate-blocked",
12141214
GenerateBlocked: true,
1215-
ReleaseBlocked: true,
12161215
},
12171216
{
12181217
LibraryID: "migrated",
12191218
NextVersion: "1.2.3",
12201219
GenerateBlocked: true,
1221-
ReleaseBlocked: true,
12221220
},
12231221
{
12241222
LibraryID: "not-previously-in-config",
12251223
GenerateBlocked: true,
1226-
ReleaseBlocked: true,
12271224
},
12281225
},
12291226
}
@@ -1236,13 +1233,13 @@ func TestBlockLegacyGenerationAndRelease(t *testing.T) {
12361233
}
12371234
}
12381235

1239-
func TestBlockLegacyGenerationAndRelease_Error(t *testing.T) {
1236+
func TestBlockLegacyGeneration_Error(t *testing.T) {
12401237
tempDir := t.TempDir()
12411238
migratedConfig := &config.Config{}
1242-
gotErr := blockLegacyGenerationAndRelease(tempDir, migratedConfig)
1239+
gotErr := blockLegacyGeneration(tempDir, migratedConfig)
12431240
wantErr := os.ErrNotExist
12441241
if !errors.Is(gotErr, wantErr) {
1245-
t.Errorf("blockLegacyGenerationAndRelease error = %v, wantErr %v", gotErr, wantErr)
1242+
t.Errorf("blockLegacyGeneration error = %v, wantErr %v", gotErr, wantErr)
12461243
}
12471244
}
12481245

0 commit comments

Comments
 (0)