Skip to content

Commit 480e910

Browse files
authored
fix(librarian): restrict update all to googleapis discovery (#3724)
Rust currently lists multiple sources (discovery, googleapis, showcase, conformance, protobuf), but updating showcase, conformance, or protobuf would require additional code changes in google-cloud-rust. Update to restrict `librarian update --all` to only update googleapis and discovery. And use it in `librarianops` command. Fix #3691
1 parent f0a6571 commit 480e910

3 files changed

Lines changed: 28 additions & 30 deletions

File tree

internal/librarian/update.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
"context"
1919
"errors"
2020
"fmt"
21-
"maps"
22-
"slices"
2321
"strings"
2422

2523
"github.com/googleapis/librarian/internal/config"
@@ -47,13 +45,19 @@ var (
4745
// updateCommand returns the `update` subcommand.
4846
func updateCommand() *cli.Command {
4947
return &cli.Command{
50-
Name: "update",
51-
Usage: "update sources to the latest version",
48+
Name: "update",
49+
Usage: "update sources to the latest version",
50+
Description: `Supported sources are:
51+
- conformance
52+
- discovery
53+
- googleapis
54+
- protobuf
55+
- showcase`,
5256
UsageText: "librarian update [--all | source]",
5357
Flags: []cli.Flag{
5458
&cli.BoolFlag{
5559
Name: "all",
56-
Usage: "update all sources",
60+
Usage: "update discovery and googleapis sources",
5761
},
5862
},
5963
Action: func(ctx context.Context, cmd *cli.Command) error {
@@ -104,7 +108,7 @@ func runUpdate(all bool, sourceName string) error {
104108

105109
var sourceNamesToProcess []string
106110
if all {
107-
sourceNamesToProcess = slices.Collect(maps.Keys(sourceRepos))
111+
sourceNamesToProcess = []string{"discovery", "googleapis"}
108112
} else {
109113
sourceNamesToProcess = []string{sourceName}
110114
}

internal/librarian/update_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,17 +422,17 @@ func TestUpdateCommand(t *testing.T) {
422422
SHA256: "this-should-be-changed",
423423
},
424424
Conformance: &config.Source{
425-
Commit: "this-should-be-changed",
426-
SHA256: "this-should-be-changed",
425+
Commit: "this-should-not-change",
426+
SHA256: "this-should-not-change",
427427
},
428428
ProtobufSrc: &config.Source{
429429
Branch: testBranch,
430-
Commit: "this-should-be-changed",
431-
SHA256: "this-should-be-changed",
430+
Commit: "this-should-not-change",
431+
SHA256: "this-should-not-change",
432432
},
433433
Showcase: &config.Source{
434-
Commit: "this-should-be-changed",
435-
SHA256: "this-should-be-changed",
434+
Commit: "this-should-not-change",
435+
SHA256: "this-should-not-change",
436436
},
437437
},
438438
},
@@ -448,17 +448,17 @@ func TestUpdateCommand(t *testing.T) {
448448
SHA256: discoveryTestSHA,
449449
},
450450
Conformance: &config.Source{
451-
Commit: conformanceTestCommit,
452-
SHA256: conformanceTestSHA,
451+
Commit: "this-should-not-change",
452+
SHA256: "this-should-not-change",
453453
},
454454
ProtobufSrc: &config.Source{
455455
Branch: testBranch,
456-
Commit: protobufTestCommit,
457-
SHA256: protobufTestSHA,
456+
Commit: "this-should-not-change",
457+
SHA256: "this-should-not-change",
458458
},
459459
Showcase: &config.Source{
460-
Commit: showcaseTestCommit,
461-
SHA256: showcaseTestSHA,
460+
Commit: "this-should-not-change",
461+
SHA256: "this-should-not-change",
462462
},
463463
},
464464
},

internal/librarianops/librarianops.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ For each repository, librarianops will:
7676
2. Create a branch: librarianops-generateall-YYYY-MM-DD
7777
3. Resolve librarian version from @main and update version field in librarian.yaml
7878
4. Run librarian tidy
79-
5. Run librarian update discovery (google-cloud-rust only)
80-
6. Run librarian update googleapis
81-
7. Run librarian generate --all
82-
8. Run cargo update --workspace (google-cloud-rust only)
83-
9. Commit changes
84-
10. Create a pull request`,
79+
5. Run librarian update --all
80+
6. Run librarian generate --all
81+
7. Run cargo update --workspace (google-cloud-rust only)
82+
8. Commit changes
83+
9. Create a pull request`,
8584
Flags: []cli.Flag{
8685
&cli.BoolFlag{
8786
Name: "all",
@@ -169,13 +168,8 @@ func processRepo(ctx context.Context, repoName, repoDir string) (err error) {
169168
return err
170169
}
171170
}
172-
if repoName == repoRust {
173-
if err := runLibrarianWithVersion(ctx, version, "update", "discovery"); err != nil {
174-
return err
175-
}
176-
}
177171
if repoName != repoFake {
178-
if err := runLibrarianWithVersion(ctx, version, "update", "googleapis"); err != nil {
172+
if err := runLibrarianWithVersion(ctx, version, "update", "--all"); err != nil {
179173
return err
180174
}
181175
}

0 commit comments

Comments
 (0)