A version that was not two spellings of itself
The Updates page read "v1.0.0 (reports 1.0.0)". That note exists to warn that a tag was cut before the version bump -- a release nobody can identify afterwards -- and it was firing on two ways of writing one version, because `git describe` answers with the tag's name and tags here carry a `v`. Stripped in `_describe`, where `resolve_target` has always stripped it and where the docstring already promised the stripped form. The mismatch check then compares two things spelled the same way, and still reports a tag that really does disagree; there is a test for each half. Found by cutting the first release, which is the only place it could have been found. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -340,7 +340,7 @@ def resolve_target(root: Path, channel: str, branch: str) -> Target | None:
|
||||
return None
|
||||
return Target(
|
||||
ref=tag,
|
||||
label=tag.lstrip("v"),
|
||||
label=tag.removeprefix("v"),
|
||||
sha=commit.sha,
|
||||
subject=commit.subject,
|
||||
notes=_notes_for(root, tag),
|
||||
@@ -362,9 +362,16 @@ def _describe(root: Path) -> str:
|
||||
bare short sha when nothing has ever been tagged. That last case is why
|
||||
`--always` is there: without it this fails outright on a repository with no
|
||||
tags, which is every repository before its first release.
|
||||
|
||||
The leading `v` comes off, because git answers with the **tag's name** and
|
||||
tags here are `v1.0.0` while `__version__` is `1.0.0`. Without this the page
|
||||
read "v1.0.0 (reports 1.0.0)" -- a note whose whole purpose is to flag a tag
|
||||
cut before a version bump, firing on two spellings of the same version. The
|
||||
first release is what showed it. `resolve_target` has always stripped it for
|
||||
the same reason, and this docstring already promised the stripped form.
|
||||
"""
|
||||
code, output = _git(["describe", "--tags", "--always", "--dirty="], cwd=root)
|
||||
return output if code == 0 else ""
|
||||
return output.removeprefix("v") if code == 0 else ""
|
||||
|
||||
|
||||
def read(*, fetch: bool = False) -> State:
|
||||
@@ -418,8 +425,8 @@ def read(*, fetch: bool = False) -> State:
|
||||
# Exactly at a tag whose name disagrees with the version this process
|
||||
# reports. No subprocess: `running` and `__version__` are both already here.
|
||||
mismatch = ""
|
||||
if RELEASE_TAG.match(running) and running.lstrip("v") != __version__:
|
||||
mismatch = running.lstrip("v")
|
||||
if RELEASE_TAG.match(running) and running != __version__:
|
||||
mismatch = running
|
||||
|
||||
return State(
|
||||
**base,
|
||||
|
||||
Reference in New Issue
Block a user