Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
54 changes: 54 additions & 0 deletions e2e/tasks/test_task_includes_glob
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

# Test glob pattern support in task_config.includes
# See: https://github.com/jdx/mise/discussions/7860

# Create a tasks directory with multiple task files
# Note: Standalone task TOML files use a different format than mise.toml
mkdir -p tasks

cat <<EOF >tasks/build.toml
[build]
run = 'echo "building"'
EOF

cat <<EOF >tasks/test.toml
[test]
run = 'echo "testing"'
EOF

cat <<EOF >tasks/deploy.toml
[deploy]
run = 'echo "deploying"'
EOF

# Create mise.toml with glob pattern in includes
cat <<EOF >mise.toml
[task_config]
includes = ["tasks/*.toml"]
EOF

# Test that all tasks are discovered via glob pattern
assert_contains "mise tasks" "build"
assert_contains "mise tasks" "test"
assert_contains "mise tasks" "deploy"

# Test that the tasks actually run
assert_contains "mise run build" "building"
assert_contains "mise run test" "testing"
assert_contains "mise run deploy" "deploying"

# Test mixing glob with literal paths
cat <<EOF >extra-tasks.toml
[extra]
run = 'echo "extra task"'
EOF

cat <<EOF >mise.toml
[task_config]
includes = ["tasks/*.toml", "extra-tasks.toml"]
EOF

assert_contains "mise tasks" "build"
assert_contains "mise tasks" "extra"
assert_contains "mise run extra" "extra task"
16 changes: 11 additions & 5 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,21 +2065,27 @@ pub fn task_includes_for_dir(dir: &Path, config_files: &ConfigMap) -> Vec<PathBu
.find_map(|cf| cf.task_config().includes.clone())
.unwrap_or_else(default_task_includes)
.into_iter()
.filter_map(|p| {
.flat_map(|p| {
// Git URLs will be handled by load_file_tasks
if p.starts_with("git::") {
None
return vec![];
}
// Check if pattern contains glob characters
if p.contains('*') || p.contains('?') || p.contains('[') {

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The glob detection logic is incomplete. Glob patterns can also contain ] (closing bracket for character classes) and { or } (for brace expansion like {a,b}). Additionally, escaped glob characters (e.g., \*) would be incorrectly treated as glob patterns. Consider using a more robust detection method or checking if the glob function returns multiple results to determine if expansion occurred.

Copilot uses AI. Check for mistakes.
// Use glob expansion
glob(dir, &p).unwrap_or_default()

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using unwrap_or_default() silently ignores glob errors, making it difficult for users to debug invalid patterns. Consider logging the error or propagating it so users receive feedback when their glob pattern is malformed.

Suggested change
glob(dir, &p).unwrap_or_default()
glob(dir, &p).unwrap_or_else(|err| {
eprintln!(
"Failed to expand glob pattern '{}' in '{}': {}",
p,
dir.display(),
err
);
Vec::new()
})

Copilot uses AI. Check for mistakes.
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
} else {
let path = PathBuf::from(p);
// Literal path - use existing logic
let path = PathBuf::from(&p);
let resolved = if path.is_absolute() {
path
} else {
dir.join(path)
};
if resolved.exists() {
Some(resolved)
vec![resolved]
} else {
None
vec![]
}
}
})
Expand Down
Loading