git-lfs/commands/commands_test.go
brian m. carlson 0245ce5aa6
commands: don't honor lfs.fetch* for ls-files
Currently, if a user runs git lfs ls-files with lfs.fetchexclude set to
*, then all files are excluded from the output.  This doesn't make much
sense, since the lfs.fetchinclude and lfs.fetchexclude options are
documented to work only on fetches.  Let's ensure that we don't load the
fetch filters by default when performing a non-fetch operation so that
git lfs ls-files isn't affected by these exclusions.
2020-03-31 13:55:24 +00:00

50 lines
1.2 KiB
Go

package commands
import (
"testing"
"github.com/git-lfs/git-lfs/config"
"github.com/stretchr/testify/assert"
)
var (
testcfg = config.NewFrom(config.Values{
Git: map[string][]string{
"lfs.fetchinclude": []string{"/default/include"},
"lfs.fetchexclude": []string{"/default/exclude"},
},
})
)
func TestDetermineIncludeExcludePathsReturnsCleanedPaths(t *testing.T) {
inc := "/some/include"
exc := "/some/exclude"
i, e := determineIncludeExcludePaths(testcfg, &inc, &exc, true)
assert.Equal(t, []string{"/some/include"}, i)
assert.Equal(t, []string{"/some/exclude"}, e)
}
func TestDetermineIncludeExcludePathsReturnsEmptyPaths(t *testing.T) {
inc := ""
exc := ""
i, e := determineIncludeExcludePaths(testcfg, &inc, &exc, true)
assert.Empty(t, i)
assert.Empty(t, e)
}
func TestDetermineIncludeExcludePathsReturnsDefaultsWhenAbsent(t *testing.T) {
i, e := determineIncludeExcludePaths(testcfg, nil, nil, true)
assert.Equal(t, []string{"/default/include"}, i)
assert.Equal(t, []string{"/default/exclude"}, e)
}
func TestDetermineIncludeExcludePathsReturnsNothingWhenAbsent(t *testing.T) {
i, e := determineIncludeExcludePaths(testcfg, nil, nil, false)
assert.Empty(t, i)
assert.Empty(t, e)
}