fix(release): bump version with a surgical edit so create-release keeps Cargo.toml comments (VA-137) #145

Merged
longjacksonle merged 1 commit from fix/VA-137-release-preserve-comments into main 2026-07-15 18:42:50 +02:00

Fixes VA-137: just create-release strips all top-level Cargo.toml comments on every release.

Root cause

The recipe bumped the version by reserializing the whole file:

open Cargo.toml | update workspace.package.version $bare | to toml | collect | save --force Cargo.toml

nushell's to toml does not preserve comments, so every release silently deleted all top-level comments. On v0.4.0 this removed the six-line block above [profile.release] documenting why the release binary keeps line-table debuginfo + the symbol table (VA-92). It was restored by hand in PR #141 and would be stripped again on the next release.

Fix

Replace the reserialization with a single anchored regex that rewrites only the version value under [workspace.package]:

open Cargo.toml --raw | str replace --regex '(\[workspace\.package\][^\[]*?\nversion = )"[^"]*"' $'${1}"($bare)"' | save --force Cargo.toml

The [^\[]*? bound stops at the next [section], so the several workspace.dependencies version = ... pins are never touched. --raw + first-match-only replace keeps the file byte-for-byte identical apart from that one string.

Validation

Tested on the real Cargo.toml with nushell 0.112.2 (the host version) across major / minor / hotfix bumps:

  • version parses to the bumped value (1.0.0, 0.5.0, 0.4.1)
  • the dependency version pins (tokio 1, etc.) are unchanged
  • all six top-level comments survive, including the VA-92 profile block
  • trailing newline preserved
  • byte diff is exactly the one version line

just --show create-release renders the recipe line unchanged (no {{ }} interference) and the justfile still parses. This unblocks the next release (VA-135 crate republish, VA-136 tag-build check) without re-stripping the comments those changes rely on.

🤖 Generated with Claude Code

Fixes VA-137: `just create-release` strips all top-level Cargo.toml comments on every release. ## Root cause The recipe bumped the version by reserializing the whole file: ```nu open Cargo.toml | update workspace.package.version $bare | to toml | collect | save --force Cargo.toml ``` nushell's `to toml` does not preserve comments, so every release silently deleted all top-level comments. On v0.4.0 this removed the six-line block above `[profile.release]` documenting why the release binary keeps line-table debuginfo + the symbol table (VA-92). It was restored by hand in PR #141 and would be stripped again on the next release. ## Fix Replace the reserialization with a single anchored regex that rewrites only the version value under `[workspace.package]`: ```nu open Cargo.toml --raw | str replace --regex '(\[workspace\.package\][^\[]*?\nversion = )"[^"]*"' $'${1}"($bare)"' | save --force Cargo.toml ``` The `[^\[]*?` bound stops at the next `[section]`, so the several `workspace.dependencies` `version = ...` pins are never touched. `--raw` + first-match-only replace keeps the file byte-for-byte identical apart from that one string. ## Validation Tested on the real Cargo.toml with nushell 0.112.2 (the host version) across major / minor / hotfix bumps: - version parses to the bumped value (`1.0.0`, `0.5.0`, `0.4.1`) - the dependency `version` pins (tokio `1`, etc.) are unchanged - all six top-level comments survive, including the VA-92 profile block - trailing newline preserved - byte diff is exactly the one version line `just --show create-release` renders the recipe line unchanged (no `{{ }}` interference) and the justfile still parses. This unblocks the next release (VA-135 crate republish, VA-136 tag-build check) without re-stripping the comments those changes rely on. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(release): bump version with a surgical edit so create-release keeps Cargo.toml comments (VA-137)
All checks were successful
Check / fmt + clippy + tests (pull_request) Successful in 6m22s
Create release / Create release from merged PR (pull_request) Has been skipped
7b75d32af3
`just create-release` bumped the workspace version by reserializing the whole file (`open Cargo.toml | update workspace.package.version | to toml | save`). nushell's `to toml` does not preserve comments, so every release silently deleted all top-level Cargo.toml comments. On v0.4.0 this stripped the six-line block above `[profile.release]` documenting why the release binary keeps line-table debuginfo and the symbol table (VA-92); it was restored by hand in PR #141 and would have been stripped again on the next release.

Replace the reserialization with a single anchored regex that rewrites only the version string under `[workspace.package]`: `open Cargo.toml --raw | str replace --regex '(\[workspace\.package\][^\[]*?\nversion = )"[^"]*"' ...`. The `[^\[]*?` bound stops at the next `[section]`, so the `workspace.dependencies` `version = ...` pins are never touched, and first-match-only replace on the raw bytes keeps the file identical apart from that one value.

Validated on the real Cargo.toml with nushell 0.112.2 (the host version) across major/minor/hotfix bumps: the version parses to the bumped value, the dependency version pins are unchanged, all six top-level comments (including the VA-92 profile block) survive, the trailing newline is preserved, and the byte diff is exactly the one version line. `just` renders the recipe line unchanged (no `{{ }}` interference) and the justfile still parses.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LYb1fkK32XQdwkGkStxXR9
Signed-off-by: longjacksonle <longjacksonle@gmail.com>
longjacksonle deleted branch fix/VA-137-release-preserve-comments 2026-07-15 18:42:51 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/vervain-agent!145
No description provided.