feat: add use_gitignore option to exclude ignored files from sources/generates (#2773)

This commit is contained in:
Valentin Maerten
2026-06-29 15:39:33 +02:00
committed by GitHub
parent a03aa7ba69
commit 616433df75
53 changed files with 1347 additions and 43 deletions

View File

@@ -38,6 +38,7 @@ type Task struct {
Method string
Prefix string `hash:"ignore"`
IgnoreError bool
UseGitignore *bool
Run string
Platforms []*Platform
If string
@@ -75,6 +76,12 @@ func (t *Task) IsSilent() bool {
return t.Silent != nil && *t.Silent
}
// ShouldUseGitignore returns true if gitignore filtering is enabled for the task.
// Returns false if UseGitignore is nil or 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.
func (t *Task) WildcardMatch(name string) (bool, []string) {
names := append([]string{t.Task}, t.Aliases...)
@@ -149,7 +156,8 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
Internal bool
Method string
Prefix string
IgnoreError bool `yaml:"ignore_error"`
IgnoreError bool `yaml:"ignore_error"`
UseGitignore *bool `yaml:"use_gitignore,omitempty"`
Run string
Platforms []*Platform
If string
@@ -190,6 +198,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
t.Method = task.Method
t.Prefix = task.Prefix
t.IgnoreError = task.IgnoreError
t.UseGitignore = deepcopy.Scalar(task.UseGitignore)
t.Run = task.Run
t.Platforms = task.Platforms
t.If = task.If
@@ -233,6 +242,7 @@ func (t *Task) DeepCopy() *Task {
Method: t.Method,
Prefix: t.Prefix,
IgnoreError: t.IgnoreError,
UseGitignore: deepcopy.Scalar(t.UseGitignore),
Run: t.Run,
IncludeVars: t.IncludeVars.DeepCopy(),
IncludedTaskfileVars: t.IncludedTaskfileVars.DeepCopy(),