fix: refresh for-loop commands after deps#2802
Open
lawrence3699 wants to merge 1 commit intogo-task:mainfrom
Open
fix: refresh for-loop commands after deps#2802lawrence3699 wants to merge 1 commit intogo-task:mainfrom
lawrence3699 wants to merge 1 commit intogo-task:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes an execution-order bug where tasks using cmds: - for: sources / for: generates could compile to an empty command list on the first run when those files are produced by dependencies. The PR refreshes the compiled command list after deps complete so loop expansion sees newly created files before fingerprinting/up-to-date checks.
Changes:
- Refactors command compilation into a reusable
compileCmdshelper. - Recompiles
t.CmdsafterrunDepsto refreshfor:loop expansion oversources/generates. - Adds a regression test covering “deps create sources used by
for: sources”.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
variables.go |
Extracts compileCmds and reuses it during task compilation. |
task.go |
Rebuilds compiled command list after dependencies finish running. |
executor_test.go |
Adds regression test to ensure for: sources expands after deps materialize files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixes #1494
When a task uses
for: sourcesand the matching files are created by a dependency, the first run can skip the task because the command list is compiled before the deps materialize those sources.The issue in #1494 looks like a fingerprint ordering bug at first, but the stale piece is actually the compiled
cmdslist.depsalready run before fingerprinting; the missing step is refreshing commands that loop oversourcesorgeneratesafter those deps finish.This patch keeps the fix scoped to that command-refresh step. It rebuilds the compiled command list after deps complete, so
for: sources/for: generatesloops see newly created files without re-running dynamicsh:vars.Reproduction
Before this change, a clean run only executed
create_deps, anduse_depscould then be treated as up to date because its compiled command list was still empty.After this change, the same first run executes the expanded
use_depscommands and prints all three generated files.Testing
go test ./... -run '^TestForCmdsRecompileAfterDeps$'go test ./...go run ./cmd/task -d /tmp/task1494-repro use_deps