-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(task): support glob patterns in task_config.includes #7870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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('[') { | ||||||||||||||||||||||
| // Use glob expansion | ||||||||||||||||||||||
| glob(dir, &p).unwrap_or_default() | ||||||||||||||||||||||
|
||||||||||||||||||||||
| 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() | |
| }) |
cursor[bot] marked this conversation as resolved.
Outdated
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.