From cdfebe3f55dc53872079a96a9a5dd6970bc2980e Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sun, 11 Jan 2026 18:43:56 +0700 Subject: lib/git: fix ignore pattern with single wildcard '*' Single wildcard should ignore everything inside it. --- lib/git/git_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lib/git/git_test.go') diff --git a/lib/git/git_test.go b/lib/git/git_test.go index 65fe572d..2ea5aba4 100644 --- a/lib/git/git_test.go +++ b/lib/git/git_test.go @@ -163,6 +163,37 @@ func TestGit_Equal(t *testing.T) { } } +func TestGit_IsIgnored(t *testing.T) { + agit, err := New(`testdata/IsIgnored/`) + if err != nil { + t.Fatal(err) + } + + listCase := []struct { + path string + exp bool + }{{ + path: `a/b/c/c1`, + exp: true, + }, { + path: `a/b/c`, + exp: true, + }, { + path: `a/b/b1`, + exp: true, + }, { + path: `a/b/.gitignore`, + }, { + path: `a/b`, + }, { + path: `a`, + }} + for _, tc := range listCase { + got := agit.IsIgnored(tc.path) + test.Assert(t, tc.path, tc.exp, got) + } +} + func TestGetRemoteURL(t *testing.T) { cases := []struct { desc string -- cgit v1.3