fix: stop freezing the draft release's tag_name after first creation #45

Merged
robin.wieske merged 1 commit from fix/44-draft-tag-name-frozen-after-creation into main 2026-10-01 06:10:08 +02:00
Member

Closes #44.

More precise than the issue's original diagnosis

The issue named create_or_update_release()'s own fallback ternary as the bug:

tag = existing_draft.get("tag_name") if existing_draft else new_tag

True, but turned out to be one level removed from the actual cause — main() itself already collapses new_tag down to the existing draft's stale tag before ever calling that function:

comparison_tag = new_tag
if existing_draft:
    comparison_tag = existing_draft["tag_name"]
...
url = self.create_or_update_release(comparison_tag, release_notes, existing_draft)

So create_or_update_release()'s parameter is literally named new_tag, but by the time it arrives it's already the old tag whenever a draft exists. Its own internal fallback never even gets a chance to matter — the value's already wrong one call frame earlier.

Fix

Both places now just always use the freshly-computed new_tag:

  • main(): removed the comparison_tag indirection entirely. The version-comparison text and the tag sent to the API both just use new_tag directly.
  • create_or_update_release(): dropped its now-fully-redundant fallback (tag = new_tag, unconditionally).

Same PATCH request already fires on every run (to refresh the notes body) — this costs nothing extra, it just lets tag_name/name get the same "always reflect current truth" treatment the notes already get. The draft's id/URL is untouched throughout; nothing gets deleted/recreated.

Not done here (discussed on #44, explicitly out of scope)

An alternative approach — delete the existing draft and create a fresh one whenever the new tag is semver-"bigger" — was considered and rejected: it discards the draft's id/URL on every escalation (breaking any open link/bookmark) and needs real semver-comparison logic to decide when to fire, for no benefit over unconditionally trusting the fresh computation.

Verification

No test suite exists in this repo. Verified with python3 -m py_compile release_drafter.py (clean) and a manual read-through of the full main() flow post-change.

🤖 Generated with Claude Code

Closes #44. ## More precise than the issue's original diagnosis The issue named `create_or_update_release()`'s own fallback ternary as the bug: ```python tag = existing_draft.get("tag_name") if existing_draft else new_tag ``` True, but turned out to be one level removed from the actual cause — `main()` itself already collapses `new_tag` down to the existing draft's stale tag *before* ever calling that function: ```python comparison_tag = new_tag if existing_draft: comparison_tag = existing_draft["tag_name"] ... url = self.create_or_update_release(comparison_tag, release_notes, existing_draft) ``` So `create_or_update_release()`'s parameter is literally named `new_tag`, but by the time it arrives it's already the *old* tag whenever a draft exists. Its own internal fallback never even gets a chance to matter — the value's already wrong one call frame earlier. ## Fix Both places now just always use the freshly-computed `new_tag`: - `main()`: removed the `comparison_tag` indirection entirely. The version-comparison text and the tag sent to the API both just use `new_tag` directly. - `create_or_update_release()`: dropped its now-fully-redundant fallback (`tag = new_tag`, unconditionally). Same `PATCH` request already fires on every run (to refresh the notes body) — this costs nothing extra, it just lets `tag_name`/`name` get the same "always reflect current truth" treatment the notes already get. The draft's `id`/URL is untouched throughout; nothing gets deleted/recreated. ## Not done here (discussed on #44, explicitly out of scope) An alternative approach — delete the existing draft and create a fresh one whenever the new tag is semver-"bigger" — was considered and rejected: it discards the draft's `id`/URL on every escalation (breaking any open link/bookmark) and needs real semver-comparison logic to decide when to fire, for no benefit over unconditionally trusting the fresh computation. ## Verification No test suite exists in this repo. Verified with `python3 -m py_compile release_drafter.py` (clean) and a manual read-through of the full `main()` flow post-change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix: stop freezing the draft release's tag_name after first creation
All checks were successful
Tag Version / update_tags (pull_request) Successful in 9s
972226c97f
generate_next_tag() recomputes the correct bump type (major/minor/patch,
from breaking-change/feature labels) from every merged PR since the last
real release, on every run. But main() only ever used that fresh value
when no draft existed yet -- once a draft was created, it silently
overwrote new_tag with the existing draft's own (possibly stale) tag
before passing it anywhere, so a later PR that should have escalated the
bump type (e.g. a feature merging after an initial fix-only draft was
already created as a patch bump) never actually took effect. The same
stale-tag fallback was duplicated one level down in
create_or_update_release() itself, now dead code with the caller fixed.

Both now just always use new_tag -- same as release_notes already do on
every run, no special-casing needed. The draft release keeps its id/URL
throughout; only its tag_name/name/body get refreshed in place via the
existing PATCH.

Fixes #44.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LFbXrghRVSfsfvm1S1A7Uc
robin.wieske deleted branch fix/44-draft-tag-name-frozen-after-creation 2026-10-01 06:10:09 +02:00
Sign in to join this conversation.
No reviewers
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
Wi3eDigital/forgejo-release-drafter-action!45
No description provided.