Skip to content

Commit

Permalink
Clean up vfs/leaf.go
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
denik committed Dec 5, 2024
1 parent 0ad790e commit ffec127
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 73 deletions.
7 changes: 3 additions & 4 deletions internal/bundle/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"github.com/databricks/cli/libs/env"
"github.com/databricks/cli/libs/filer"
"github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/git"
"github.com/databricks/cli/libs/template"
"github.com/databricks/cli/libs/vfs"
"github.com/databricks/databricks-sdk-go"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -144,15 +144,14 @@ func getBundleRemoteRootPath(w *databricks.WorkspaceClient, t *testing.T, unique
}

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

t.Setenv("BUNDLE_ROOT", root)

// Create the command
cmd := exec.Command("go", append([]string{"run", "main.go"}, args...)...)
cmd.Dir = gitRoot.Native()
cmd.Dir = gitRoot

// Create buffers to capture output
var outBuffer, errBuffer bytes.Buffer
Expand Down
4 changes: 2 additions & 2 deletions libs/git/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func ensureWorkspacePrefix(p string) string {
func fetchRepositoryInfoDotGit(ctx context.Context, path string) (RepositoryInfo, error) {
result := RepositoryInfo{}

rootDir, err := findLeafInTree(path, GitDirectoryName)
rootDir, err := FindLeafInTree(path, GitDirectoryName)
if rootDir == "" {
return result, err
}
Expand Down Expand Up @@ -135,7 +135,7 @@ func fetchRepositoryInfoDotGit(ctx context.Context, path string) (RepositoryInfo
return result, nil
}

func findLeafInTree(p string, leafName string) (string, error) {
func FindLeafInTree(p string, leafName string) (string, error) {
var err error
for i := 0; i < 10000; i++ {
_, err = os.Stat(filepath.Join(p, leafName))
Expand Down
29 changes: 0 additions & 29 deletions libs/vfs/leaf.go

This file was deleted.

38 changes: 0 additions & 38 deletions libs/vfs/leaf_test.go

This file was deleted.

0 comments on commit ffec127

Please sign in to comment.