Make the compiled snapshot see uncommitted CLI sources - #75
Closed
MAUstaoglu wants to merge 1 commit into
Closed
Conversation
`tool_revision` decides whether bin/cache/flutter-tvos.snapshot is stale, and its git branch returned `git rev-parse HEAD` -- which describes what was committed, not what is on disk. In a development checkout those differ constantly, so editing anything under lib/ and running the CLI silently executed the previously compiled snapshot. The failure mode is the reason this is worth fixing rather than documenting. The change does not appear to be ignored; it appears to be wrong. You get the same build, the same error, byte for byte, and conclude the fix is incorrect -- when it never ran. `rm bin/cache/flutter-tvos.snapshot` was the folk remedy, for anyone who had been told it. The non-git branch of this same function never had the problem: it hashes the contents of bin/ and lib/, so it is content-addressed by construction. This makes the git branch agree, by folding uncommitted work into the revision. - Scoped to bin, lib, pubspec.yaml and pubspec.lock, so editing a README or a test does not force a recompile. - Hashes `status --porcelain` *and* `diff HEAD`: names and statuses alone would collide across two different edits to the same file, and the diff alone would miss a newly added one. - Only paid when the tree is dirty. A clean checkout returns the bare 40-character sha exactly as before, so nobody who is not editing the CLI sees any change. Nine tests drive the real function in a throwaway git repository. Six of them fail against the unfixed version; the three that pass either way are the ones asserting the unchanged behaviour, which is what they are for.
Member
Author
|
Folded into #74 so 1.10.0 lands as one release — the two fixes are the same piece of work, and the snapshot bug is what made the first one look broken while I was writing it. Same commits, same tests. |
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.
The problem
tool_revisioninbin/internal/shared.shdecides whetherbin/cache/flutter-tvos.snapshotis stale. Its git branch returnedgit rev-parse HEAD— which describes what was committed, not what is on disk.In a development checkout those differ constantly. Edit anything under
lib/, run the CLI, and it silently executes the previously compiled snapshot.The failure mode is why this is worth fixing rather than documenting. The change does not appear to be ignored — it appears to be wrong. You get the same build, the same error, byte for byte, and conclude the fix is incorrect when in fact it never ran.
rm bin/cache/flutter-tvos.snapshotis the folk remedy, for anyone who has been told it.It cost me a full build cycle and a byte-identical error I nearly misread as "my patch doesn't work".
The fix
The non-git branch of this same function never had the problem — it hashes the contents of
bin/andlib/, so it is content-addressed by construction. This makes the git branch agree, by folding uncommitted work into the revision.bin,lib,pubspec.yaml,pubspec.lock, so editing a README or a test does not force a recompile.status --porcelainanddiff HEAD. Names and statuses alone would collide across two different edits to the same file; the diff alone would miss a newly added one.Tests
Nine cases in
test/general/tvos_snapshot_revision_test.dart, driving the real bash function in a throwaway git repository: clean checkout returns bare HEAD; edits underlib/andbin/move it; a new untracked source moves it; two different edits to one file do not collide; the value is deterministic rather than a nonce; reverting restores it; README/test edits do not move it; committing returns to a bare sha.Six of the nine fail against the unfixed
shared.sh. The three that pass either way are the ones asserting unchanged behaviour, which is what they are for.Baseline
The suite is not currently green on
main: 58 failures there, and the same 58 here. Passes go 373 → 382, exactly the nine added.Note on versioning
No version bump here deliberately — #74 is open and bumps to 1.10.0, and a second bump would just conflict. This should ride whichever release lands next.