fix(task): prefer exact task name over extension-stripped match#10393
Conversation
When a TOML task and an auto-discovered file task differ only by extension -- e.g. `[tasks.hello] file = "mise-tasks/hello.sh"` alongside the discovered file task `hello.sh` -- `mise run hello` matched both (the matcher treated an exact name and an extension-stripped name as equal precedence) and ran the script twice concurrently. In GetMatchingExt::get_matching, run an exact-match pass first and only fall back to extension-stripped matches when nothing matched exactly. This applies to both the simple-name branch and the monorepo/glob branch (so `//pkg:hello` is likewise not joined by `//pkg:hello.sh`). `mise run build` still resolves a `build.js` file task when no exact "build" task exists. Addresses discussion jdx#10298. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes a task resolution bug where a TOML-defined task could simultaneously match auto-discovered file-task scripts with different extensions. The core algorithm now prefers exact task-key matches over extension-stripped matches, with fallback behavior preserved for cases where no exact match exists (e.g., resolving ChangesTask Matching Priority Fix
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Greptile SummaryFixes a double-run regression (#10298) where
Confidence Score: 5/5The change is narrowly scoped to the task-matching logic and preserves all pre-existing behaviour; the extension-stripped fallback path, wildcard patterns, and monorepo path matching are all unchanged. Both touched branches of No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(task): prefer exact task name over e..." | Re-trigger Greptile |
Problem
A TOML task whose
filepoints at a script in an auto-discovered file-task dir runs the script twice, concurrently. Reported in #10298:Root cause
Scripts in
mise-tasks/are auto-discovered as file tasks named with their extension (hello.sh), while[tasks.hello]is a separate task namedhello. They don''t collide, so both exist.GetMatchingExt::get_matchingthen matched the patternhelloagainst both, because it treated an exact name match and an extension-stripped match (hello.sh→hello) with equal precedence — so both tasks ran.Fix
Run an exact-match pass first, and only fall back to extension-stripped matches when nothing matched exactly. This applies to both code paths in
get_matching:mise run hello), and//pkg:hello, so//pkg:hellomust not also pull in//pkg:hello.sh). The per-entry match was factored into a small closure run in two passes (exact, then extension-stripped fallback).The extension-stripped fallback is preserved, so
mise run buildstill resolves abuild.jsfile task when no exactbuildtask exists (and the existinge2e/tasks/test_task_monorepo_file_taskscases — running monorepo file tasks with and without their extension — keep working). Path matching and*wildcard patterns are unchanged.Testing
hellovshello.sh) and the monorepo form (//pkg:hellovs//pkg:hello.sh), plus the extension-stripped fallback when no exact match exists.e2e/tasks/test_task_file_toml_no_double_run: assertsmise run helloruns the script exactly once and the[hello.sh]file task does not also run.cargo fmt --all -- --checkpasses.Addresses #10298
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests