Skip to content

Commit 3c2d0e4

Browse files
authored
chore(internal/librarian/rust): remove unused function (#3306)
Removes getPackageName that retrieves the packagename from a Cargo.toml file. It is never used other than test. For #3203
1 parent a399580 commit 3c2d0e4

2 files changed

Lines changed: 0 additions & 27 deletions

File tree

internal/librarian/rust/helper.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ package rust
1818
import (
1919
"context"
2020
"fmt"
21-
"os"
2221
"path"
2322

2423
"github.com/googleapis/librarian/internal/command"
25-
"github.com/pelletier/go-toml/v2"
2624
)
2725

2826
// RustHelper interface used for mocking in tests.
@@ -45,20 +43,6 @@ func (r *RustHelp) HelperFormatAndValidateLibrary(ctx context.Context, outputDir
4543
return FormatAndValidateLibrary(ctx, outputDir)
4644
}
4745

48-
// getPackageName retrieves the packagename from a Cargo.toml file.
49-
func getPackageName(output string) (string, error) {
50-
cargo := CargoConfig{}
51-
filename := path.Join(output, "Cargo.toml")
52-
contents, err := os.ReadFile(filename)
53-
if err != nil {
54-
return "", fmt.Errorf("failed to read %s: %w", filename, err)
55-
}
56-
if err = toml.Unmarshal(contents, &cargo); err != nil {
57-
return "", fmt.Errorf("error unmarshaling %s: %w", filename, err)
58-
}
59-
return cargo.Package.Name, nil
60-
}
61-
6246
// PrepareCargoWorkspace creates a new cargo package in the specified output directory.
6347
func PrepareCargoWorkspace(ctx context.Context, outputDir string) error {
6448
if err := VerifyRustTools(ctx); err != nil {

internal/librarian/rust/helper_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@ import (
2626
"github.com/googleapis/librarian/internal/testhelpers"
2727
)
2828

29-
func TestGetPackageName(t *testing.T) {
30-
expectedPackageName := "new-lib-format"
31-
got, err := getPackageName("testdata/new-lib-format")
32-
if err != nil {
33-
t.Fatalf("error getting package name %v", err)
34-
}
35-
if got != expectedPackageName {
36-
t.Errorf("want packageName %s, got %s", expectedPackageName, got)
37-
}
38-
}
39-
4029
func TestPrepareCargoWorkspace(t *testing.T) {
4130
testhelpers.RequireCommand(t, "cargo")
4231
testhelpers.RequireCommand(t, "taplo")

0 commit comments

Comments
 (0)