Skip to content

Commit ffec127

Browse files
committed
Clean up vfs/leaf.go
The git module now uses alternative implementation that uses os module + strings as path directly (#1945). The remaining use case is also updated to use git.FindLeafInTree, as it's a better fit.
1 parent 0ad790e commit ffec127

File tree

4 files changed

+5
-73
lines changed

4 files changed

+5
-73
lines changed

internal/bundle/helpers.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"github.com/databricks/cli/libs/env"
1919
"github.com/databricks/cli/libs/filer"
2020
"github.com/databricks/cli/libs/flags"
21+
"github.com/databricks/cli/libs/git"
2122
"github.com/databricks/cli/libs/template"
22-
"github.com/databricks/cli/libs/vfs"
2323
"github.com/databricks/databricks-sdk-go"
2424
"github.com/stretchr/testify/require"
2525
)
@@ -144,15 +144,14 @@ func getBundleRemoteRootPath(w *databricks.WorkspaceClient, t *testing.T, unique
144144
}
145145

146146
func blackBoxRun(t *testing.T, root string, args ...string) (stdout string, stderr string) {
147-
cwd := vfs.MustNew(".")
148-
gitRoot, err := vfs.FindLeafInTree(cwd, ".git")
147+
gitRoot, err := git.FindLeafInTree(".", ".git")
149148
require.NoError(t, err)
150149

151150
t.Setenv("BUNDLE_ROOT", root)
152151

153152
// Create the command
154153
cmd := exec.Command("go", append([]string{"run", "main.go"}, args...)...)
155-
cmd.Dir = gitRoot.Native()
154+
cmd.Dir = gitRoot
156155

157156
// Create buffers to capture output
158157
var outBuffer, errBuffer bytes.Buffer

libs/git/info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func ensureWorkspacePrefix(p string) string {
105105
func fetchRepositoryInfoDotGit(ctx context.Context, path string) (RepositoryInfo, error) {
106106
result := RepositoryInfo{}
107107

108-
rootDir, err := findLeafInTree(path, GitDirectoryName)
108+
rootDir, err := FindLeafInTree(path, GitDirectoryName)
109109
if rootDir == "" {
110110
return result, err
111111
}
@@ -135,7 +135,7 @@ func fetchRepositoryInfoDotGit(ctx context.Context, path string) (RepositoryInfo
135135
return result, nil
136136
}
137137

138-
func findLeafInTree(p string, leafName string) (string, error) {
138+
func FindLeafInTree(p string, leafName string) (string, error) {
139139
var err error
140140
for i := 0; i < 10000; i++ {
141141
_, err = os.Stat(filepath.Join(p, leafName))

libs/vfs/leaf.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

libs/vfs/leaf_test.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)