fix(add): preserve user keys & interior comments on tool overwrite#7
Merged
Merged
Conversation
write_tool rebuilt [tool.ohbin.tools.<name>] from scratch, keeping only the generated ToolConfig fields plus trailing trivia. Re-publishing an existing tool therefore dropped any user-authored key (e.g. password_committed_ok), ate interior comments, and could inject a stray blank line before the next section. Overwrite an existing entry in place instead: update only the generated fields and asset hashes, leaving extra keys, interior comments, and the trailing comment block untouched. The common re-publish keeps the same platform set, so asset sub-tables are updated value-by-value with no structural change; a changed set reconciles (update/keep/drop/append) rather than emptying the table, which previously perturbed the leading blank line. Regression tests cover same-set and changed-set overwrites.
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.
TL;DR
write_toolrebuilt[tool.ohbin.tools.<name>]from scratch, so re-publishing anexisting tool silently dropped user-authored keys (e.g.
password_committed_ok),ate interior comments, and could inject a stray blank line before the next section.
It now overwrites an existing entry in place, touching only the generated fields.
The bug
add-gist/addoverwrites go throughwrite_tool, which built a brand-new tablefrom the resolved
ToolConfigand kept only the known fields plus the trailingcomment block. Everything else in the table was lost:
password_committed_okThe fix
When the entry already exists, mutate it in place instead of rebuilding:
repo/version/binary/encrypted/password) and the per-platform asset hashes;value-by-value — zero structural change, so surrounding trivia is preserved exactly;
empty-and-rebuild, which previously perturbed the leading blank line.
Testing
key, the interior comment, the sibling section's layout, and the absence of doubled
blank lines all survive an overwrite;
ruff format+ruff checkclean;pyrightreports0 errors;
add-gistagainst a real consumer's pyproject isnow idempotent and preserves
password_committed_ok.Bumps the package version to
0.2.3.