From 9525b2b24ed4071bf8a43082c70350312bdcebe6 Mon Sep 17 00:00:00 2001 From: Arman Rahman Date: Mon, 19 Jul 2021 21:18:18 +0000 Subject: [PATCH 1/2] remove os specific paths --- pkg/ignore/ignore_test.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pkg/ignore/ignore_test.go b/pkg/ignore/ignore_test.go index 36d021b5..b487f51f 100644 --- a/pkg/ignore/ignore_test.go +++ b/pkg/ignore/ignore_test.go @@ -2,7 +2,7 @@ package ignore import ( "os" - "runtime" + "path/filepath" "testing" "github.com/rs/zerolog" @@ -17,15 +17,9 @@ func TestIgnore_Match(t *testing.T) { i := NewIgnore([]string{"my/files/*"}) assert.NotNil(t, i) - assert.False(t, i.Match("not/foo")) - assert.True(t, i.Match("my/files/file1")) - assert.False(t, i.Match("my/files")) - - if runtime.GOOS == "windows" { - assert.False(t, i.Match(`not\foo`)) - assert.True(t, i.Match(`my\files\file1`)) - assert.False(t, i.Match(`my\files`)) - } + assert.False(t, i.Match(filepath.Join("not", "foo"))) + assert.True(t, i.Match(filepath.Join("my", "files", "file1"))) + assert.False(t, i.Match(filepath.Join("my", "files"))) } // Test all default ignore files, except for .git/info/exclude, since From 725c315c980abf086ac4e58002dcb57a6468296b Mon Sep 17 00:00:00 2001 From: Arman Rahman Date: Wed, 28 Jul 2021 20:37:00 +0000 Subject: [PATCH 2/2] add windows ignore tests back in --- pkg/ignore/ignore_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/ignore/ignore_test.go b/pkg/ignore/ignore_test.go index b487f51f..5df40443 100644 --- a/pkg/ignore/ignore_test.go +++ b/pkg/ignore/ignore_test.go @@ -17,6 +17,11 @@ func TestIgnore_Match(t *testing.T) { i := NewIgnore([]string{"my/files/*"}) assert.NotNil(t, i) + // Test if rules with backslashes match on windows + assert.False(t, i.Match("not/foo")) + assert.True(t, i.Match("my/files/file1")) + assert.False(t, i.Match("my/files")) + assert.False(t, i.Match(filepath.Join("not", "foo"))) assert.True(t, i.Match(filepath.Join("my", "files", "file1"))) assert.False(t, i.Match(filepath.Join("my", "files")))