mirror of https://github.com/databricks/cli.git
switch to folders.FindDirWithLeaf
This commit is contained in:
parent
8b5bb37019
commit
dab674bbdb
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue