Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 6 additions & 3 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,8 +135,11 @@ func fetchRepositoryInfoDotGit(ctx context.Context, path string) (RepositoryInfo
return result, nil
}

func findLeafInTree(p string, leafName string) (string, error) {
var err error
func FindLeafInTree(p string, leafName string) (string, error) {
p, err := filepath.Abs(p)
if err != nil {
return "", err
}
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.

Loading