[eas-cli] Skip rewriting unchanged screenshots in metadata:pull#3846
Open
ahmdshrif wants to merge 1 commit into
Open
[eas-cli] Skip rewriting unchanged screenshots in metadata:pull#3846ahmdshrif wants to merge 1 commit into
ahmdshrif wants to merge 1 commit into
Conversation
|
Subscribed to pull request
Generated by CodeMention |
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.
Why
Fixes #3804.
Running
eas metadata:pullmarks every downloaded screenshot as changed on each invocation, even when nothing about the image changed. App Store Connect embeds a unique asset resource ID into each screenshot'seXIf(UserComment) andiTXt(Adobe XMP) PNG chunks on every download, so the downloaded bytes always differ from the local file — while the decoded image (IDAT) is byte-for-byte identical.downloadScreenshotAsyncwrites the response buffer unconditionally, so every pull dirties version control with meaningless diffs.How
isPngEquivalent(a, b)inmetadata/utils/png.ts: walks both buffers' PNG chunk sequences and compares them ignoring the volatile metadata chunks (tEXt,zTXt,iTXt,eXIf,tIME). All other chunks — including all pixel data — must match exactly. Falls back to plain byte equality when either buffer is not a structurally valid PNG, so non-PNG assets keep today's behavior.downloadScreenshotAsync, when a local file already exists at the output path, the write is skipped if the existing file is PNG-equivalent to the downloaded buffer (logged asScreenshot unchanged). The config entry still points at the same relative path, sometadata.json/sync behavior is unchanged.No new dependencies — the chunk walk is ~30 lines over the documented PNG structure (8-byte signature + length/type/data/CRC chunks).
Test Plan
yarn test src/metadata— 16 suites, 195 tests pass, including:isPngEquivalent(metadata/utils/__tests__/png.test.ts): equivalent when onlyiTXt/eXIf/tEXtdiffer, not equivalent whenIDAT/PLTEdiffer, byte-equality fallback for non-PNG buffers, truncated-PNG safety;screenshots.test.ts): a pull where the local file differs from the download only in theiTXtchunk does not callfs.promises.writeFile, and still writes the config entry.yarn lint,yarn fmt:check,yarn typecheck— clean (remaining warnings/errors are pre-existing onmainand untouched by this PR).eas metadata:pulltwice in a git-tracked project with existing screenshots — before this change every screenshot shows as modified on the second pull; after,git statusstays clean.