fix: make generate_handlers.js idempotent for untouched output - #44
Open
BhariGowda wants to merge 1 commit into
Open
fix: make generate_handlers.js idempotent for untouched output#44BhariGowda wants to merge 1 commit into
BhariGowda wants to merge 1 commit into
Conversation
isStubHandler() decided whether to protect a handler file from being overwritten by checking for the presence of any 'function' keyword. But generate_handlers.js's own output always contains real function declarations (with '// TODO: wire call' placeholder bodies, by design) - so the very first time it's run, then run again with zero edits, the second run reports 'contains edits — use --force to overwrite' even though nothing was ever touched. Reproduced end-to-end with a synthetic Foundry project: generate once, re-run with no changes, no --force -> incorrectly skipped every time. Fix: compare the file on disk against what would be generated right now. If byte-identical, it's genuinely untouched and safe to overwrite - this is what makes re-running the script after a selection change idempotent instead of permanently requiring --force. Falls back to the original 'no function keyword' check to still correctly treat generate_suite.js's true empty shell as a stub. Verified all four states: missing file (write), generate_suite.js's empty shell (write), untouched prior output with same inputs (write - previously incorrectly skipped), and a genuine user edit (still correctly skipped and preserved).
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.
isStubHandler() decided whether to protect a handler file from being overwritten by checking for the presence of any
functionkeyword. But generate_handlers.js's own output always contains real function declarations (with// TODO: wire callplaceholder bodies, by design) so the very first time it's run, then run again with zero edits, the second run reports "contains edits use --force to overwrite" even though nothing was ever touched.Reproduced end-to-end with a synthetic Foundry project: generate once, re-run with no changes, no
--force→ incorrectly skipped every time.Fix: compare the file on disk against what would be generated right now. If byte-identical, it's genuinely untouched and safe to overwrite this is what makes re-running the script after a selection change idempotent instead of permanently requiring
--force. Falls back to the original "no function keyword" check to still correctly treatgenerate_suite.js's true empty shell as a stub.Verified all four states: missing file (write),
generate_suite.js's empty shell (write), untouched prior output with same inputs (write previously incorrectly skipped), and a genuine user edit (still correctly skipped and preserved).