fix(content): correctness fixes for push, merge, and delete#2721
Open
catalan-adobe wants to merge 1 commit intoadobe:mainfrom
Open
fix(content): correctness fixes for push, merge, and delete#2721catalan-adobe wants to merge 1 commit intoadobe:mainfrom
catalan-adobe wants to merge 1 commit intoadobe:mainfrom
Conversation
* push: --path now uses exact-or-trailing-slash matching, so `--path /blog` no longer matches `/blog2/post.html`. * push: do not advance refs/da/synced when a --path filter excludes other ahead changes — those would otherwise be silently considered already synced on the next run. * push: rely on the error counts returned by _uploadFiles and _deleteFiles instead of re-reading the input arrays. processQueue consumes its input via shift(), so putTargets.every(...) and deleted.every(...) were vacuously true and the synced ref was advanced on every push even when uploads or deletes failed. * merge: pass the project root (not content/) to getValidToken so the cached login is reused across content subcommands and .hlx/.da-token.json is not written inside the content repo. * da-api: deleteSource throws on non-2xx (matching putSource) and treats 404 as success (idempotent delete). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Five correctness fixes to the
aem contentsubcommand, all insrc/content/. The load-bearing one was discovered while writing tests for the others.push.cmd.js--pathexact-or-trailing-slash matching.--path /blogno longer matches/blog2/post.html. Mirrors the existing pattern inadd.cmd.js(filepathInContentAddScope).--path. When a--pathfilter excludes other ahead changes, the synced ref is no longer advanced to HEAD; the user is told to re-run without--pathto fully sync. Otherwise the next push computes an empty diff and silently drops the unfiltered changes.processQueuemutation gotcha.processQueueconsumes its input array viashift(), so the priorputTargets.every(p => successfullyPushed.has(p))anddeleted.every(p => successfullyDeleted.has(p))checks were vacuouslytrueand the synced ref was advanced on every push — even when uploads or deletes failed. Now uses the error counts returned by_uploadFiles/_deleteFiles. The methods also defensively copy their input internally.merge.cmd.jsgetValidTokennow receives the project root (this._dir) instead ofcontentDir. The cached login is reused across content subcommands, and.hlx/.da-token.jsonis no longer written inside the inner content git repo.da-api.jsdeleteSourceerror shape. Now throws on non-2xx (matchingputSource) and treats 404 as success (idempotent delete). Previously a 5xx returnedfalsesilently, and_deleteFilesdidn't check the return value, so server failures were logged as✓ deleted.Test plan
node_modules/.bin/mocha test/content/ test/content-metadata-html.test.js— 188 passingnpm test(full suite) — 479 passing, 3 environmental failures intest/git-utils.test.js(isomorphic-git can't resolve tags through a worktree'sgitdir:indirection; reproduces on unmodifiedmainfrom any worktree)eslint .cleanda-api.test.js: delete throws on 5xx; delete treats 404 as successmerge.cmd.test.js: project root passed togetValidTokenpush.cmd.test.js:--path /blogdoesn't bleed to/blog2; synced ref held back under--path; synced ref advanced when--pathcovers all ahead changes; synced ref held back when a delete fails on the server🤖 Generated with Claude Code