Repository navigation
fix: run once with multiple levels of nested includes - #3097
Open
sainimal1ba-hue wants to merge 1 commit into
Open
sainimal1ba-hue wants to merge 1 commit into
sainimal1ba-hue wants to merge 1 commit into
Conversation
run: once deduplicates executions by hashing the defining Taskfile location together with the task's LocalName. LocalName trims the task Namespace off its full name, but Namespace only ever held the last include namespace instead of the whole chain. With more than one level of nesting, the intermediate namespaces survived the trim, so the same task reached through different branches produced different hashes and ran once per branch. Accumulate the namespace at every merge level so LocalName always returns the task name relative to the Taskfile that defines it. The deduplication key is now the same for the same underlying task no matter which path through the include tree reaches it. Fixes go-task#3058
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #3058
run: once should mean that a task is only run once per invocation regardless of how many include branches reach it. That only works if the hierarchy is one level deep at present. With two or more levels the same task runs once per branch:
task: [c:a:tools:exe] echo "building tool"
building tool
task: [c:b:tools:exe] echo "building tool"
building tool
Root cause: Task deduplicates by hashing the Taskfile location (the defining Taskfile location) plus the task's LocalName. LocalName strips off the Namespace from the full name, but Namespace only ever stored the last include namespace (not the full chain). In a deeper tree the middle namespaces survive the trim so c:a:tools:exe becomes tools/taskfile.yml:a:tools:exe and c:b:tools:exe becomes tools/taskfile.yml:b:tools:exe. Different hashes, no dedupe.
Fix: Tasks.Merge now accumulates the namespace at each level so the chain is always the full c:a:tools and LocalName just returns 'exe' (the name of the task relative to the Taskfile that defines it). Both branches hash to tools/taskfile.yml:exe and the second call simply joins the first execution rather than re-executing it.
Tests
AI disclosure
GLM 5.3 was the version used to build the solution. I reviewed all the implementation, verified the root cause and ran the tests myse
Checklist