Skip to content

Commit

Permalink
CR Fixes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
N-o-Z committed Aug 3, 2023
1 parent 4cf07d5 commit 1af5109
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/lakectl/cmd/local_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var localListCmd = &cobra.Command{
Headers: []interface{}{
"Directory",
"Remote URI",
"Last synced HEAD",
"Synced commit",
},
Rows: rows,
},
Expand Down
1 change: 0 additions & 1 deletion pkg/git/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
)

var (
ErrGitError = errors.New("git error")
ErrNotARepository = errors.New("not a git repository")
ErrNoGit = errors.New("no git support")
)
2 changes: 1 addition & 1 deletion pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func GetRepositoryPath(dir string) (string, error) {
if strings.Contains(out, "not a git repository") {
return "", ErrNotARepository
}
return "", fmt.Errorf("%s: %w", out, ErrGitError)
return "", fmt.Errorf("%s: %w", out, err)
}

func createEntriesForIgnore(dir string, paths []string, exclude bool) ([]string, error) {
Expand Down
12 changes: 6 additions & 6 deletions pkg/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/treeverse/lakefs/pkg/git"
)

func TestIsGitRepository(t *testing.T) {
func TestIsRepository(t *testing.T) {
tmpdir := t.TempDir()
tmpSubdir, err := os.MkdirTemp(tmpdir, "")
require.NoError(t, err)
Expand All @@ -35,7 +35,7 @@ func TestIsGitRepository(t *testing.T) {
require.True(t, git.IsRepository(tmpSubdir))
}

func TestGetGitRepositoryPath(t *testing.T) {
func TestGetRepositoryPath(t *testing.T) {
tmpdir := t.TempDir()
tmpSubdir, err := os.MkdirTemp(tmpdir, "")
require.NoError(t, err)
Expand All @@ -50,15 +50,15 @@ func TestGetGitRepositoryPath(t *testing.T) {
_, err = git.GetRepositoryPath(tmpdir)
require.ErrorIs(t, err, git.ErrNotARepository)
_, err = git.GetRepositoryPath(tmpFile.Name())
require.ErrorIs(t, err, git.ErrGitError)
require.Error(t, err)

// Init git repo on root
require.NoError(t, exec.Command("git", "init", "-q", tmpdir).Run())
gitPath, err := git.GetRepositoryPath(tmpdir)
require.NoError(t, err)
require.Equal(t, tmpdir, gitPath)
_, err = git.GetRepositoryPath(tmpFile.Name())
require.ErrorIs(t, err, git.ErrGitError)
require.Error(t, err)
gitPath, err = git.GetRepositoryPath(tmpSubdir)
require.NoError(t, err)
require.Equal(t, tmpdir, gitPath)
Expand All @@ -85,7 +85,7 @@ func TestIgnore(t *testing.T) {
_, err = git.Ignore(tmpdir, []string{}, []string{}, marker)
require.ErrorIs(t, err, git.ErrNotARepository)
_, err = git.Ignore(tmpFile.Name(), []string{}, []string{}, marker)
require.ErrorIs(t, err, git.ErrGitError)
require.Error(t, err)

// Init git repo on tmpdir
require.NoError(t, exec.Command("git", "init", "-q", tmpdir).Run())
Expand All @@ -107,7 +107,7 @@ func TestIgnore(t *testing.T) {
verifyPathTracked(t, []string{filepath.Base(tmpSubdir), trackedFile})

_, err = git.Ignore(tmpFile.Name(), []string{}, []string{excludedPath}, marker)
require.ErrorIs(t, err, git.ErrGitError)
require.Error(t, err)
result, err := git.Ignore(tmpdir, []string{}, []string{excludedPath}, marker)
require.NoError(t, err)
require.Equal(t, ignorePath, result)
Expand Down
5 changes: 3 additions & 2 deletions pkg/local/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ func ReadIndex(path string) (*Index, error) {
if err != nil {
return nil, err
}
idx := &Index{}
idx := &Index{
root: filepath.Dir(idxPath),
}
err = yaml.Unmarshal(data, idx)
idx.root = filepath.Dir(idxPath)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 1af5109

Please sign in to comment.