chore(release): 0.1.2 - no-op write returns success#13
Merged
Conversation
Writing byte-identical content to an existing doc failed: writeDoc ran `git commit` with no staged diff, which errors "nothing to commit, working tree clean" and surfaced as an error (HTTP 400 / CLI exit 1) instead of success. A no-op write must succeed - write overwrites the whole doc, so identical content means the doc is already in the desired state. Fix: after staging, short-circuit when `git status --porcelain` shows no pending change; return the current HEAD rev + the path's last-commit time instead of creating an empty commit. This also covers edit no-ops (str_replace with identical result, frontmatter merge that changes nothing) since edit routes through writeDoc. delete is unaffected - it is guarded by existsSync, so it always has a real deletion diff. Tests: no-op write returns success with the unchanged rev; edit no-op (str_replace-identical, frontmatter-no-change) returns success.
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.
Bug
Writing byte-identical content to an existing doc failed.
writeDocrunsgit commitafter staging, but with no staged diff git errorsnothing to commit, working tree clean. That rejection surfaced to callers as an error (HTTP 400 / CLI exit 1) instead of success.Per the write contract a no-op write MUST be a success:
writeoverwrites the whole doc, so identical content means the doc is already in the desired state.Found by an adversarial verifier running against the cli.
Fix
src/backends/local-backend.tswriteDoc: aftergit add, short-circuit whengit status --porcelain -- <path>reports no pending change. Return the currentHEADrev + the path's last-commit time instead of creating an empty commit (cleaner than--allow-empty, which would spam empty commits).Audit: edit / delete
writeDoc, so it inherits the fix. Reachable no-op edits now succeed:str_replacewith an identical result, and a frontmatter merge that changes nothing.existsSyncbefore committing, so it always has a real deletion diff and never hits the empty-commit path.Tests
no-op write (byte-identical content) returns success, no new commit- asserts the rev is unchanged (short-circuited before an empty commit).no-op edit (str_replace with identical result) returns success.no-op edit (frontmatter merge changes nothing) returns success.npm run verifygreen locally (type-check + lint + format + 52 tests + build).Release
Version bump
0.1.1->0.1.2. Thechore(release):subject triggers the publish workflow on merge to master.