fix(release): read the version after checking out the base - #82
Conversation
`cmd_prepare` read the current version before switching to the base branch, so the bump was computed from whatever branch the script happened to be on. Running it from any other branch cuts a release numbered off unrelated history. `scripts/release.sh` in hotdata-ibis already has this ordering; this brings the rest in line.
Moving the version read below the checkout also moved the bump-kind validation, which lives inside bump_version. A typo then switched the caller to the base branch before failing. Check the argument next to the existing emptiness check, using the same pattern the explicit-version branch already accepts, so an argument error exits without side effects as it did before.
|
Follow-up applied here too, for consistency across the family. Reviewers on four of the sibling PRs noticed that moving the version read below the checkout also moved the bump-kind validation, since it lives inside
|
The explicit-version regex appeared in both the argument check and the branch that takes the argument verbatim, so a change to the accepted format had to be made twice. Hoist it to VERSION_RE, alongside BUMP_KIND_RE. Also narrow the comment above the check: an unchanged version and a pre-release suffix are found from the base branch version, so those necessarily fail after the checkout and the comment should not imply otherwise.
|
Two follow-ups from review applied across all seven repos in this family, so they stay identical:
Accept/reject behaviour is unchanged: |
The bug
scripts/release.sh cmd_preparereads the current version before it switches to the base branch:So the bump is computed from the branch the script happened to be invoked on, not from the branch being released.
How it shows up
Hit for real while releasing another repo in this family. On a stale branch at
0.10.0,prepare minorcomputed0.11.0, then checked out main at0.16.0:That failure was luck. It only errored because the version tool refuses downgrades and the branch happened to be behind. From a branch that is ahead of the base, the computed version is higher, nothing refuses it, and a release is cut under the wrong number with no error at all.
The fix
Move the version read below the checkout, so it reads the base branch.
hotdata-ibisalready orders it this way; this brings the rest of the family in line. Pure block move plus a comment — no behaviour change when the script is run from an already-current base branch, which is the documented path.Scope
The same defect is in seven repos sharing this script. Companion PRs are open in each.