diff --git a/internal/fingerprint/glob.go b/internal/fingerprint/glob.go index c87c9ec3..930a54a3 100644 --- a/internal/fingerprint/glob.go +++ b/internal/fingerprint/glob.go @@ -10,7 +10,7 @@ import ( "github.com/go-task/task/v3/taskfile/ast" ) -func Globs(dir string, globs []*ast.Glob, gitignore bool) ([]string, error) { +func Globs(dir string, globs []*ast.Glob, useGitignore bool) ([]string, error) { resultMap := make(map[string]bool) for _, g := range globs { matches, err := glob(dir, g.Glob) @@ -22,7 +22,7 @@ func Globs(dir string, globs []*ast.Glob, gitignore bool) ([]string, error) { } } - if gitignore { + if useGitignore { resultMap = filterGitignored(resultMap, dir) } diff --git a/internal/fingerprint/sources_checksum.go b/internal/fingerprint/sources_checksum.go index ef9e7387..9ffdbdb6 100644 --- a/internal/fingerprint/sources_checksum.go +++ b/internal/fingerprint/sources_checksum.go @@ -89,7 +89,7 @@ func (*ChecksumChecker) Kind() string { } func (c *ChecksumChecker) checksum(t *ast.Task) (string, error) { - sources, err := Globs(t.Dir, t.Sources, t.IsGitignore()) + sources, err := Globs(t.Dir, t.Sources, t.ShouldUseGitignore()) if err != nil { return "", err } diff --git a/internal/fingerprint/sources_timestamp.go b/internal/fingerprint/sources_timestamp.go index 5d482851..929b044b 100644 --- a/internal/fingerprint/sources_timestamp.go +++ b/internal/fingerprint/sources_timestamp.go @@ -28,7 +28,7 @@ func (checker *TimestampChecker) IsUpToDate(t *ast.Task) (bool, error) { return false, nil } - sources, err := Globs(t.Dir, t.Sources, t.IsGitignore()) + sources, err := Globs(t.Dir, t.Sources, t.ShouldUseGitignore()) if err != nil { return false, nil } @@ -54,7 +54,7 @@ func (checker *TimestampChecker) IsUpToDate(t *ast.Task) (bool, error) { } } - generates, err := Globs(t.Dir, t.Generates, t.IsGitignore()) + generates, err := Globs(t.Dir, t.Generates, t.ShouldUseGitignore()) if err != nil { return false, nil } @@ -112,7 +112,7 @@ func (checker *TimestampChecker) Kind() string { // Value implements the Checker Interface func (checker *TimestampChecker) Value(t *ast.Task) (any, error) { - sources, err := Globs(t.Dir, t.Sources, t.IsGitignore()) + sources, err := Globs(t.Dir, t.Sources, t.ShouldUseGitignore()) if err != nil { return time.Now(), err } diff --git a/taskfile/ast/task.go b/taskfile/ast/task.go index f7f0f318..bff0ff59 100644 --- a/taskfile/ast/task.go +++ b/taskfile/ast/task.go @@ -38,7 +38,7 @@ type Task struct { Method string Prefix string `hash:"ignore"` IgnoreError bool - Gitignore *bool + UseGitignore *bool Run string Platforms []*Platform If string @@ -76,10 +76,10 @@ func (t *Task) IsSilent() bool { return t.Silent != nil && *t.Silent } -// IsGitignore returns true if the task has gitignore filtering explicitly enabled. -// Returns false if Gitignore is nil (not set) or explicitly set to false. -func (t *Task) IsGitignore() bool { - return t.Gitignore != nil && *t.Gitignore +// ShouldUseGitignore returns true if the task has gitignore filtering explicitly enabled. +// Returns false if UseGitignore is nil (not set) or explicitly set to false. +func (t *Task) ShouldUseGitignore() bool { + return t.UseGitignore != nil && *t.UseGitignore } // WildcardMatch will check if the given string matches the name of the Task and returns any wildcard values. @@ -157,7 +157,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error { Method string Prefix string IgnoreError bool `yaml:"ignore_error"` - Gitignore *bool `yaml:"gitignore,omitempty"` + UseGitignore *bool `yaml:"use_gitignore,omitempty"` Run string Platforms []*Platform If string @@ -198,7 +198,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error { t.Method = task.Method t.Prefix = task.Prefix t.IgnoreError = task.IgnoreError - t.Gitignore = deepcopy.Scalar(task.Gitignore) + t.UseGitignore = deepcopy.Scalar(task.UseGitignore) t.Run = task.Run t.Platforms = task.Platforms t.If = task.If @@ -242,7 +242,7 @@ func (t *Task) DeepCopy() *Task { Method: t.Method, Prefix: t.Prefix, IgnoreError: t.IgnoreError, - Gitignore: deepcopy.Scalar(t.Gitignore), + UseGitignore: deepcopy.Scalar(t.UseGitignore), Run: t.Run, IncludeVars: t.IncludeVars.DeepCopy(), IncludedTaskfileVars: t.IncludedTaskfileVars.DeepCopy(), diff --git a/taskfile/ast/taskfile.go b/taskfile/ast/taskfile.go index 125b2670..30dcbc8a 100644 --- a/taskfile/ast/taskfile.go +++ b/taskfile/ast/taskfile.go @@ -34,7 +34,7 @@ type Taskfile struct { Dotenv []string Run string Interval time.Duration - Gitignore bool + UseGitignore bool `yaml:"use_gitignore"` } // Merge merges the second Taskfile into the first @@ -90,7 +90,7 @@ func (tf *Taskfile) UnmarshalYAML(node *yaml.Node) error { Dotenv []string Run string Interval time.Duration - Gitignore bool + UseGitignore bool `yaml:"use_gitignore"` } if err := node.Decode(&taskfile); err != nil { return errors.NewTaskfileDecodeError(err, node) @@ -108,7 +108,7 @@ func (tf *Taskfile) UnmarshalYAML(node *yaml.Node) error { tf.Dotenv = taskfile.Dotenv tf.Run = taskfile.Run tf.Interval = taskfile.Interval - tf.Gitignore = taskfile.Gitignore + tf.UseGitignore = taskfile.UseGitignore if tf.Includes == nil { tf.Includes = NewIncludes() } diff --git a/testdata/gitignore/Taskfile.yml b/testdata/gitignore/Taskfile.yml index c78e5a0e..93452867 100644 --- a/testdata/gitignore/Taskfile.yml +++ b/testdata/gitignore/Taskfile.yml @@ -1,6 +1,6 @@ version: '3' -gitignore: true +use_gitignore: true tasks: build: @@ -13,8 +13,8 @@ tasks: - ./generated.txt method: checksum - build-no-gitignore: - gitignore: false + build-no-use_gitignore: + use_gitignore: false cmds: - cp ./source.txt ./generated.txt sources: diff --git a/variables.go b/variables.go index 18d716a5..2fbe1f9b 100644 --- a/variables.go +++ b/variables.go @@ -59,7 +59,7 @@ func (e *Executor) CompiledTaskForTaskList(call *Call) (*ast.Task, error) { Env: nil, Dotenv: origTask.Dotenv, Silent: deepcopy.Scalar(origTask.Silent), - Gitignore: deepcopy.Scalar(origTask.Gitignore), + UseGitignore: deepcopy.Scalar(origTask.UseGitignore), Interactive: origTask.Interactive, Internal: origTask.Internal, Method: origTask.Method, @@ -111,9 +111,9 @@ func (e *Executor) compiledTask(call *Call, evaluateShVars bool) (*ast.Task, err } } - gitignore := origTask.IsGitignore() - if origTask.Gitignore == nil { - gitignore = e.Taskfile.Gitignore + gitignore := origTask.ShouldUseGitignore() + if origTask.UseGitignore == nil { + gitignore = e.Taskfile.UseGitignore } new := ast.Task{ @@ -132,7 +132,7 @@ func (e *Executor) compiledTask(call *Call, evaluateShVars bool) (*ast.Task, err Env: nil, Dotenv: templater.Replace(origTask.Dotenv, cache), Silent: deepcopy.Scalar(origTask.Silent), - Gitignore: &gitignore, + UseGitignore: &gitignore, Interactive: origTask.Interactive, Internal: origTask.Internal, Method: templater.Replace(origTask.Method, cache), diff --git a/watch.go b/watch.go index 349dd57a..1a0dbee0 100644 --- a/watch.go +++ b/watch.go @@ -205,7 +205,7 @@ func (e *Executor) collectSources(calls []*Call) ([]string, error) { var sources []string err := e.traverse(calls, func(task *ast.Task) error { - files, err := fingerprint.Globs(task.Dir, task.Sources, task.IsGitignore()) + files, err := fingerprint.Globs(task.Dir, task.Sources, task.ShouldUseGitignore()) if err != nil { return err } diff --git a/website/src/public/schema.json b/website/src/public/schema.json index 37751fa4..61f7a843 100644 --- a/website/src/public/schema.json +++ b/website/src/public/schema.json @@ -177,7 +177,7 @@ "enum": ["none", "checksum", "timestamp"], "default": "none" }, - "gitignore": { + "use_gitignore": { "description": "When set to true, files matching .gitignore rules will be excluded from sources and generates glob resolution. Overrides the global gitignore setting.", "type": "boolean", "default": false @@ -692,7 +692,7 @@ "enum": ["none", "checksum", "timestamp"], "default": "checksum" }, - "gitignore": { + "use_gitignore": { "description": "When set to true, files matching .gitignore rules will be excluded from sources and generates glob resolution for all tasks. Can be overridden per task.", "type": "boolean", "default": false