Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -987,3 +987,12 @@ func TestIncludeChecksum(t *testing.T) {
WithFixtureTemplating(),
)
}

func TestColonSeparatedSources(t *testing.T) {
t.Parallel()
NewExecutorTest(t,
WithExecutorOptions(
task.WithDir("testdata/colon_sources"),
),
)
}
25 changes: 20 additions & 5 deletions internal/templater/templater.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,26 @@ func ReplaceGlobs(globs []*ast.Glob, cache *Cache) []*ast.Glob {
return nil
}

new := make([]*ast.Glob, len(globs))
for i, g := range globs {
new[i] = &ast.Glob{
Glob: Replace(g.Glob, cache),
Negate: g.Negate,
var new []*ast.Glob
for _, g := range globs {
replacedGlob := Replace(g.Glob, cache)

if strings.Contains(replacedGlob, ":") {
paths := strings.Split(replacedGlob, ":")
for _, path := range paths {
path = strings.TrimSpace(path)
if path != "" {
new = append(new, &ast.Glob{
Glob: path,
Negate: g.Negate,
})
}
}
} else {
new = append(new, &ast.Glob{
Glob: replacedGlob,
Negate: g.Negate,
})
}
}
return new
Expand Down
14 changes: 14 additions & 0 deletions testdata/colon_sources/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'

vars:
MULTI_SOURCES: "*.txt:subdir/*.md"

tasks:
default:
desc: Test colon-separated sources
sources:
- "{{.MULTI_SOURCES}}"
generates:
- output.txt
cmds:
- echo "Processing colon-separated sources" > output.txt
1 change: 1 addition & 0 deletions testdata/colon_sources/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Processing colon-separated sources
1 change: 1 addition & 0 deletions testdata/colon_sources/subdir/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Test
1 change: 1 addition & 0 deletions testdata/colon_sources/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test content
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
task: Task "default" is up to date
4 changes: 3 additions & 1 deletion website/src/docs/reference/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,14 +537,16 @@ tasks:
#### `sources`

- **Type**: `[]string` or `[]Glob`
- **Description**: Source files to monitor for changes
- **Description**: Source files to monitor for changes. Multiple glob patterns can be specified in a single string separated by colons.

```yaml
tasks:
build:
sources:
- '**/*.go'
- go.mod
# Multiple patterns in one line (colon-separated)
- '*.js:*.ts:assets/**/*'
# With exclusions
- exclude: '**/*_test.go'
cmds:
Expand Down
2 changes: 1 addition & 1 deletion website/src/public/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
}
},
"sources": {
"description": "A list of sources to check before running this task. Relevant for `checksum` and `timestamp` methods. Can be file paths or star globs.",
"description": "A list of sources to check before running this task. Relevant for `checksum` and `timestamp` methods. Can be file paths or star globs. Multiple glob patterns can be specified in a single string separated by colons.",
"type": "array",
"items": {
"$ref": "#/definitions/glob"
Expand Down