diff --git a/internal/fingerprint/gitignore_test.go b/internal/fingerprint/gitignore_test.go index 1c5118f8..edef18b1 100644 --- a/internal/fingerprint/gitignore_test.go +++ b/internal/fingerprint/gitignore_test.go @@ -19,10 +19,7 @@ func initGitRepo(t *testing.T, dir string) { func TestGlobsWithGitignore(t *testing.T) { t.Parallel() - dir, err := os.MkdirTemp("", "task-gitignore-test-*") - require.NoError(t, err) - t.Cleanup(func() { os.RemoveAll(dir) }) - + dir := t.TempDir() initGitRepo(t, dir) require.NoError(t, os.WriteFile(filepath.Join(dir, "included.txt"), []byte("included"), 0o644)) @@ -70,10 +67,7 @@ func TestGlobsWithGitignore(t *testing.T) { func TestGlobsWithGitignoreNested(t *testing.T) { t.Parallel() - dir, err := os.MkdirTemp("", "task-gitignore-nested-*") - require.NoError(t, err) - t.Cleanup(func() { os.RemoveAll(dir) }) - + dir := t.TempDir() initGitRepo(t, dir) subDir := filepath.Join(dir, "sub") @@ -82,9 +76,7 @@ func TestGlobsWithGitignoreNested(t *testing.T) { require.NoError(t, os.WriteFile(filepath.Join(subDir, "keep.txt"), []byte("keep"), 0o644)) require.NoError(t, os.WriteFile(filepath.Join(subDir, "build.out"), []byte("build"), 0o644)) - // Root .gitignore ignores *.log require.NoError(t, os.WriteFile(filepath.Join(dir, ".gitignore"), []byte("*.log\n"), 0o644)) - // Nested .gitignore ignores *.out require.NoError(t, os.WriteFile(filepath.Join(subDir, ".gitignore"), []byte("*.out\n"), 0o644)) globs := []*ast.Glob{ @@ -102,7 +94,9 @@ func TestGlobsWithGitignoreNested(t *testing.T) { func TestGlobsWithGitignoreNoRepo(t *testing.T) { t.Parallel() - dir, err := os.MkdirTemp("", "task-gitignore-norepo-*") + // Cannot use t.TempDir() here because it creates a dir inside the + // go-task repo which has a .git parent, defeating the "no repo" test. + dir, err := os.MkdirTemp("", "task-gitignore-norepo-*") //nolint:usetesting require.NoError(t, err) t.Cleanup(func() { os.RemoveAll(dir) }) diff --git a/taskfile/ast/task.go b/taskfile/ast/task.go index 30212ab6..f7f0f318 100644 --- a/taskfile/ast/task.go +++ b/taskfile/ast/task.go @@ -156,7 +156,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error { Internal bool Method string Prefix string - IgnoreError bool `yaml:"ignore_error"` + IgnoreError bool `yaml:"ignore_error"` Gitignore *bool `yaml:"gitignore,omitempty"` Run string Platforms []*Platform diff --git a/taskfile/ast/taskfile.go b/taskfile/ast/taskfile.go index 9216f396..125b2670 100644 --- a/taskfile/ast/taskfile.go +++ b/taskfile/ast/taskfile.go @@ -20,16 +20,16 @@ var ErrIncludedTaskfilesCantHaveDotenvs = errors.New("task: Included Taskfiles c // Taskfile is the abstract syntax tree for a Taskfile type Taskfile struct { - Location string - Version *semver.Version - Output Output - Method string - Includes *Includes - Set []string - Shopt []string - Vars *Vars - Env *Vars - Tasks *Tasks + Location string + Version *semver.Version + Output Output + Method string + Includes *Includes + Set []string + Shopt []string + Vars *Vars + Env *Vars + Tasks *Tasks Silent bool Dotenv []string Run string @@ -77,18 +77,18 @@ func (tf *Taskfile) UnmarshalYAML(node *yaml.Node) error { switch node.Kind { case yaml.MappingNode: var taskfile struct { - Version *semver.Version - Output Output - Method string - Includes *Includes - Set []string - Shopt []string - Vars *Vars - Env *Vars - Tasks *Tasks - Silent bool - Dotenv []string - Run string + Version *semver.Version + Output Output + Method string + Includes *Includes + Set []string + Shopt []string + Vars *Vars + Env *Vars + Tasks *Tasks + Silent bool + Dotenv []string + Run string Interval time.Duration Gitignore bool }