From 5c858b37bd35405169c2507c82b23d0b6deaef35 Mon Sep 17 00:00:00 2001 From: Valentin Maerten Date: Fri, 3 Jul 2026 16:14:17 +0200 Subject: [PATCH] test: self-manage .git in gitignore fixture tests The use_gitignore filtering resolves a repo root by walking up to a .git entry. An in-tree checkout inherits go-task's own .git, but a GitHub source tarball (common for distro packaging) has none, which silently disabled filtering and broke the golden fixtures. Have the gitignore integration tests create and clean up their own .git marker in the fixture dir so they validate real behavior regardless of the build source. --- task_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/task_test.go b/task_test.go index dd92f8eef5..b56930e77e 100644 --- a/task_test.go +++ b/task_test.go @@ -681,6 +681,12 @@ type gitignoreSeq struct { func (s gitignoreSeq) run(t *testing.T) { t.Helper() cleanup := func() { + // The fixture manages its own .git marker so that gitignore filtering + // resolves a repo root regardless of the build source: an in-tree + // checkout would otherwise inherit the go-task .git, but a GitHub + // source tarball has none, which would silently disable filtering and + // break the golden fixtures. + _ = os.RemoveAll(filepathext.SmartJoin(s.dir, ".git")) _ = os.RemoveAll(filepathext.SmartJoin(s.dir, ".task")) for name := range s.create { _ = os.Remove(filepathext.SmartJoin(s.dir, name)) @@ -694,6 +700,7 @@ func (s gitignoreSeq) run(t *testing.T) { } cleanup() t.Cleanup(cleanup) + require.NoError(t, os.MkdirAll(filepathext.SmartJoin(s.dir, ".git"), 0o755)) for name, content := range s.create { writeFile(t, s.dir, name, content) }