diff --git a/internal/bundle/helpers.go b/internal/bundle/helpers.go index 0129f50c24..00a941c952 100644 --- a/internal/bundle/helpers.go +++ b/internal/bundle/helpers.go @@ -18,7 +18,7 @@ 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/folders" "github.com/databricks/cli/libs/template" "github.com/databricks/databricks-sdk-go" "github.com/stretchr/testify/require" @@ -144,7 +144,7 @@ func getBundleRemoteRootPath(w *databricks.WorkspaceClient, t *testing.T, unique } func blackBoxRun(t *testing.T, root string, args ...string) (stdout string, stderr string) { - gitRoot, err := git.FindLeafInTree(".", ".git") + gitRoot, err := folders.FindDirWithLeaf(".", ".git") require.NoError(t, err) t.Setenv("BUNDLE_ROOT", root) diff --git a/libs/git/info.go b/libs/git/info.go index 8523df24a2..b958026565 100644 --- a/libs/git/info.go +++ b/libs/git/info.go @@ -11,6 +11,7 @@ import ( "strings" "github.com/databricks/cli/libs/dbr" + "github.com/databricks/cli/libs/folders" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/vfs" "github.com/databricks/databricks-sdk-go" @@ -105,7 +106,7 @@ func ensureWorkspacePrefix(p string) string { func fetchRepositoryInfoDotGit(ctx context.Context, path string) (RepositoryInfo, error) { result := RepositoryInfo{} - rootDir, err := FindLeafInTree(path, GitDirectoryName) + rootDir, err := folders.FindDirWithLeaf(path, GitDirectoryName) if rootDir == "" { return result, err } diff --git a/libs/git/info_test.go b/libs/git/info_test.go deleted file mode 100644 index 1294935874..0000000000 --- a/libs/git/info_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package git - -import ( - "os" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestFindLeafInTree(t *testing.T) { - wd, err := os.Getwd() - require.NoError(t, err) - - root := filepath.Join(wd, "..", "..") - - // Find from working directory should work. - { - out, err := FindLeafInTree(wd, ".git") - assert.NoError(t, err) - assert.Equal(t, root, out) - } - - // Find from project root itself should work. - { - out, err := FindLeafInTree(root, ".git") - assert.NoError(t, err) - assert.Equal(t, root, out) - } - - // Find for something that doesn't exist should work. - { - out, err := FindLeafInTree(root, "this-leaf-doesnt-exist-anywhere") - assert.NoError(t, err) - assert.Equal(t, "", out) - } -}