fix: publish tag guard - v<version> must be among git tag --points-at (v0.12.1)
The first live run of daedalus publish on the v0.12.0 release was rejected by its own tag guard: git describe --exact-match returns whichever name git picks (here: latest), not the version tag, when several tags share the release commit. The guard now checks that v<version> is among git tag --points-at HEAD; moving tags on the same commit are fine (publish spec 3.3.2, reproduced by a new test). Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -10,6 +10,18 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|||||||
|
|
||||||
- Nothing yet.
|
- Nothing yet.
|
||||||
|
|
||||||
|
## [0.12.1] - 2026-11-19
|
||||||
|
|
||||||
|
### Fixed in 0.12.1
|
||||||
|
|
||||||
|
- `publish`'s tag guard rejected a correctly tagged release when
|
||||||
|
`latest` (or any other tag) shared the release commit: `git describe
|
||||||
|
--tags --exact-match` returns whichever name git picks, not the
|
||||||
|
version tag. The guard now checks that `v<version>` is among
|
||||||
|
`git tag --points-at HEAD` (membership check, publish spec item
|
||||||
|
3.3.2); moving tags on the same commit are fine. Found by the first
|
||||||
|
live run of `daedalus publish` on the v0.12.0 release.
|
||||||
|
|
||||||
## [0.12.0] - 2026-11-19
|
## [0.12.0] - 2026-11-19
|
||||||
|
|
||||||
### Added in 0.12.0
|
### Added in 0.12.0
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ def test_path_with_extra_words_is_a_usage_error(fake_registry, plain, capsys):
|
|||||||
assert "usage: daedalus --path <name>" in capsys.readouterr().err
|
assert "usage: daedalus --path <name>" in capsys.readouterr().err
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("installed, expected", [(True, "daedalus 1.2.3"), (False, "daedalus 0.12.0")])
|
@pytest.mark.parametrize("installed, expected", [(True, "daedalus 1.2.3"), (False, "daedalus 0.12.1")])
|
||||||
def test_version(monkeypatch, capsys, installed, expected):
|
def test_version(monkeypatch, capsys, installed, expected):
|
||||||
"""--version uses metadata or pyproject.toml in a checkout."""
|
"""--version uses metadata or pyproject.toml in a checkout."""
|
||||||
def fake_version(_name):
|
def fake_version(_name):
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "daedalus"
|
name = "daedalus"
|
||||||
version = "0.12.0"
|
version = "0.12.1"
|
||||||
description = "Template for daedalus: loose scripts in one repo, run with: daedalus <name> [args...]"
|
description = "Template for daedalus: loose scripts in one repo, run with: daedalus <name> [args...]"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
|
|||||||
@@ -118,12 +118,13 @@ def cmd_publish(args: argparse.Namespace, run_cmd=None,
|
|||||||
"or stash first - what ships must be committed "
|
"or stash first - what ships must be committed "
|
||||||
"(item 3.3.1)")
|
"(item 3.3.1)")
|
||||||
return EXIT_DIRTY
|
return EXIT_DIRTY
|
||||||
code, output = run_cmd(["git", "describe", "--tags", "--exact-match",
|
code, output = run_cmd(["git", "tag", "--points-at", "HEAD"], cwd=root)
|
||||||
"HEAD"], cwd=root)
|
tags = [line.strip() for line in output.splitlines() if line.strip()]
|
||||||
if code != 0 or output.strip() != f"v{version}":
|
if code != 0 or f"v{version}" not in tags:
|
||||||
LOGGER.error("HEAD is not exactly tagged v%s; tag the release "
|
LOGGER.error("v%s is not among the tags pointing at HEAD "
|
||||||
"first: git tag -a v%s -m \"...\" (item 3.3.2)",
|
"(found: %s); tag the release first: git tag -a "
|
||||||
version, version)
|
"v%s -m \"...\" (item 3.3.2)",
|
||||||
|
version, tags or "none", version)
|
||||||
return EXIT_TAG
|
return EXIT_TAG
|
||||||
for module in ("build", "twine"):
|
for module in ("build", "twine"):
|
||||||
code, _output = run_cmd([PY, "-m", module, "--version"], cwd=root)
|
code, _output = run_cmd([PY, "-m", module, "--version"], cwd=root)
|
||||||
|
|||||||
@@ -39,9 +39,11 @@ are cited as `publish spec item N.M`.
|
|||||||
- **3.3.1** Dirty working tree (`git status --porcelain` in the
|
- **3.3.1** Dirty working tree (`git status --porcelain` in the
|
||||||
repo root, any output) is exit 3 - what ships must be what is
|
repo root, any output) is exit 3 - what ships must be what is
|
||||||
committed, and the tag must cover the exact tree.
|
committed, and the tag must cover the exact tree.
|
||||||
- **3.3.2** HEAD not exactly tagged `v<version>`
|
- **3.3.2** `v<version>` not among the tags that point at HEAD
|
||||||
(`git describe --tags --exact-match HEAD`) is exit 4 - tag
|
(`git tag --points-at HEAD`) is exit 4 - tag the release
|
||||||
first: `git tag -a v<version> -m ...`.
|
first: `git tag -a v<version> -m ...`. Other tags on the
|
||||||
|
same commit (`latest`, `stable`) are fine; the guard checks
|
||||||
|
membership, not the name git happens to pick.
|
||||||
- **3.3.3** The interpreter must provide `python -m build` and
|
- **3.3.3** The interpreter must provide `python -m build` and
|
||||||
`python -m twine` (`--version` probe each); a failure is exit 5
|
`python -m twine` (`--version` probe each); a failure is exit 5
|
||||||
with the inject hint (`pipx inject daedalus build twine`, or
|
with the inject hint (`pipx inject daedalus build twine`, or
|
||||||
@@ -108,4 +110,5 @@ are cited as `publish spec item N.M`.
|
|||||||
- **7.1** Packaging truth: SPEC items 9.1-9.5, 9.2.1.
|
- **7.1** Packaging truth: SPEC items 9.1-9.5, 9.2.1.
|
||||||
- **7.2** Repository rules: SPEC items 6.6 (tests), 9.8 (version
|
- **7.2** Repository rules: SPEC items 6.6 (tests), 9.8 (version
|
||||||
bump).
|
bump).
|
||||||
- **7.3** History: `CHANGELOG.md` entry 0.12.0.
|
- **7.3** History: `CHANGELOG.md` entries 0.12.0 (script),
|
||||||
|
0.12.1 (tag-guard fix, found by the first live run).
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ def test_app_version_falls_back_to_pyproject(monkeypatch):
|
|||||||
raise hello.importlib.metadata.PackageNotFoundError(_name)
|
raise hello.importlib.metadata.PackageNotFoundError(_name)
|
||||||
|
|
||||||
monkeypatch.setattr(hello.importlib.metadata, "version", not_found)
|
monkeypatch.setattr(hello.importlib.metadata, "version", not_found)
|
||||||
assert hello.app_version() == "0.12.0"
|
assert hello.app_version() == "0.12.1"
|
||||||
|
|
||||||
|
|
||||||
def test_help_exits_zero(capsys):
|
def test_help_exits_zero(capsys):
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ def clean_runner(version, calls=None):
|
|||||||
py = publish.PY
|
py = publish.PY
|
||||||
return make_runner({
|
return make_runner({
|
||||||
("git", "status"): (0, ""),
|
("git", "status"): (0, ""),
|
||||||
("git", "describe"): (0, f"v{version}\n"),
|
("git", "tag", "--points-at"): (0, f"v{version}\n"),
|
||||||
(py, "-m", "build", "--version"): (0, "build 1.6.1\n"),
|
(py, "-m", "build", "--version"): (0, "build 1.6.1\n"),
|
||||||
(py, "-m", "twine", "--version"): (0, "twine 7.0.0\n"),
|
(py, "-m", "twine", "--version"): (0, "twine 7.0.0\n"),
|
||||||
(py, "-m", "build"): (0, "Successfully built\n"),
|
(py, "-m", "build"): (0, "Successfully built\n"),
|
||||||
@@ -61,7 +61,7 @@ def test_dirty_tree_stops_before_building():
|
|||||||
args = publish.parse_args([])
|
args = publish.parse_args([])
|
||||||
assert publish.cmd_publish(args, runner,
|
assert publish.cmd_publish(args, runner,
|
||||||
lambda _u: 404) == 3
|
lambda _u: 404) == 3
|
||||||
assert not any(cmd[0] == "git" and cmd[1] == "describe"
|
assert not any(cmd[:2] == ["git", "tag"]
|
||||||
or cmd[1:3] == ["-m", "build"]
|
or cmd[1:3] == ["-m", "build"]
|
||||||
for cmd, _cwd in calls)
|
for cmd, _cwd in calls)
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ def test_tag_mismatch_stops():
|
|||||||
calls = []
|
calls = []
|
||||||
runner = make_runner({
|
runner = make_runner({
|
||||||
("git", "status"): (0, ""),
|
("git", "status"): (0, ""),
|
||||||
("git", "describe"): (0, "v0.0.1\n"),
|
("git", "tag", "--points-at"): (0, "v0.0.1\n"),
|
||||||
}, calls)
|
}, calls)
|
||||||
args = publish.parse_args([])
|
args = publish.parse_args([])
|
||||||
assert publish.cmd_publish(args, runner,
|
assert publish.cmd_publish(args, runner,
|
||||||
@@ -79,15 +79,40 @@ def test_tag_mismatch_stops():
|
|||||||
|
|
||||||
|
|
||||||
def test_tag_probe_failure_stops():
|
def test_tag_probe_failure_stops():
|
||||||
"""An untagged HEAD (describe fails) is exit 4."""
|
"""An untagged HEAD (no tag points at it) is exit 4."""
|
||||||
runner = make_runner({
|
runner = make_runner({
|
||||||
("git", "status"): (0, ""),
|
("git", "status"): (0, ""),
|
||||||
("git", "describe"): (128, "no tag\n"),
|
("git", "tag", "--points-at"): (1, ""),
|
||||||
})
|
})
|
||||||
assert publish.cmd_publish(publish.parse_args([]), runner,
|
assert publish.cmd_publish(publish.parse_args([]), runner,
|
||||||
lambda _u: 404) == 4
|
lambda _u: 404) == 4
|
||||||
|
|
||||||
|
|
||||||
|
def test_moving_tags_on_the_same_commit_do_not_confuse_the_guard():
|
||||||
|
"""`latest` sharing the release commit is fine (item 3.3.2).
|
||||||
|
|
||||||
|
git's own name picking is not the contract; v<version>
|
||||||
|
among the tags that point at HEAD is. Live case: git
|
||||||
|
prints `latest` for a commit tagged both latest and
|
||||||
|
v<version>.
|
||||||
|
"""
|
||||||
|
calls = []
|
||||||
|
runner = make_runner({
|
||||||
|
("git", "status"): (0, ""),
|
||||||
|
("git", "tag", "--points-at"):
|
||||||
|
(0, f"latest\nv{repo_version()}\n"),
|
||||||
|
(publish.PY, "-m", "build", "--version"): (0, "build\n"),
|
||||||
|
(publish.PY, "-m", "twine", "--version"): (0, "twine\n"),
|
||||||
|
(publish.PY, "-m", "build"): (0, "ok\n"),
|
||||||
|
(publish.PY, "-m", "twine", "check"): (0, "PASSED\n"),
|
||||||
|
}, calls)
|
||||||
|
assert publish.cmd_publish(publish.parse_args([]), runner,
|
||||||
|
lambda _u: 404) == 0
|
||||||
|
tag_calls = [cmd for cmd, _ in calls
|
||||||
|
if cmd[:2] == ["git", "tag"]]
|
||||||
|
assert tag_calls == [["git", "tag", "--points-at", "HEAD"]]
|
||||||
|
|
||||||
|
|
||||||
def repo_version():
|
def repo_version():
|
||||||
"""The version the checkout's pyproject carries."""
|
"""The version the checkout's pyproject carries."""
|
||||||
_name, version = publish.read_project(
|
_name, version = publish.read_project(
|
||||||
@@ -99,7 +124,7 @@ def test_tooling_missing_stops():
|
|||||||
"""No build/twine in the interpreter is exit 5."""
|
"""No build/twine in the interpreter is exit 5."""
|
||||||
runner = make_runner({
|
runner = make_runner({
|
||||||
("git", "status"): (0, ""),
|
("git", "status"): (0, ""),
|
||||||
("git", "describe"): (0, f"v{repo_version()}\n"),
|
("git", "tag", "--points-at"): (0, f"v{repo_version()}\n"),
|
||||||
(publish.PY, "-m", "build", "--version"): (127, "no module"),
|
(publish.PY, "-m", "build", "--version"): (127, "no module"),
|
||||||
(publish.PY, "-m", "twine", "--version"): (0, "twine\n"),
|
(publish.PY, "-m", "twine", "--version"): (0, "twine\n"),
|
||||||
})
|
})
|
||||||
@@ -112,7 +137,7 @@ def test_already_on_pypi_stops():
|
|||||||
calls = []
|
calls = []
|
||||||
runner = make_runner({
|
runner = make_runner({
|
||||||
("git", "status"): (0, ""),
|
("git", "status"): (0, ""),
|
||||||
("git", "describe"): (0, f"v{repo_version()}\n"),
|
("git", "tag", "--points-at"): (0, f"v{repo_version()}\n"),
|
||||||
(publish.PY, "-m", "build", "--version"): (0, "build\n"),
|
(publish.PY, "-m", "build", "--version"): (0, "build\n"),
|
||||||
(publish.PY, "-m", "twine", "--version"): (0, "twine\n"),
|
(publish.PY, "-m", "twine", "--version"): (0, "twine\n"),
|
||||||
}, calls)
|
}, calls)
|
||||||
@@ -126,7 +151,7 @@ def test_pypi_unreachable_stops():
|
|||||||
"""A blind publish is refused: unreachable PyPI is exit 6."""
|
"""A blind publish is refused: unreachable PyPI is exit 6."""
|
||||||
runner = make_runner({
|
runner = make_runner({
|
||||||
("git", "status"): (0, ""),
|
("git", "status"): (0, ""),
|
||||||
("git", "describe"): (0, f"v{repo_version()}\n"),
|
("git", "tag", "--points-at"): (0, f"v{repo_version()}\n"),
|
||||||
(publish.PY, "-m", "build", "--version"): (0, "build\n"),
|
(publish.PY, "-m", "build", "--version"): (0, "build\n"),
|
||||||
(publish.PY, "-m", "twine", "--version"): (0, "twine\n"),
|
(publish.PY, "-m", "twine", "--version"): (0, "twine\n"),
|
||||||
})
|
})
|
||||||
@@ -175,7 +200,7 @@ def test_build_failure_is_7():
|
|||||||
py = publish.PY
|
py = publish.PY
|
||||||
runner = make_runner({
|
runner = make_runner({
|
||||||
("git", "status"): (0, ""),
|
("git", "status"): (0, ""),
|
||||||
("git", "describe"): (0, f"v{version}\n"),
|
("git", "tag", "--points-at"): (0, f"v{version}\n"),
|
||||||
(py, "-m", "build", "--version"): (0, "build\n"),
|
(py, "-m", "build", "--version"): (0, "build\n"),
|
||||||
(py, "-m", "twine", "--version"): (0, "twine\n"),
|
(py, "-m", "twine", "--version"): (0, "twine\n"),
|
||||||
(py, "-m", "build"): (1, "error\n"),
|
(py, "-m", "build"): (1, "error\n"),
|
||||||
@@ -191,7 +216,7 @@ def test_check_failure_is_8():
|
|||||||
py = publish.PY
|
py = publish.PY
|
||||||
runner = make_runner({
|
runner = make_runner({
|
||||||
("git", "status"): (0, ""),
|
("git", "status"): (0, ""),
|
||||||
("git", "describe"): (0, f"v{version}\n"),
|
("git", "tag", "--points-at"): (0, f"v{version}\n"),
|
||||||
(py, "-m", "build", "--version"): (0, "build\n"),
|
(py, "-m", "build", "--version"): (0, "build\n"),
|
||||||
(py, "-m", "twine", "--version"): (0, "twine\n"),
|
(py, "-m", "twine", "--version"): (0, "twine\n"),
|
||||||
(py, "-m", "build"): (0, "ok\n"),
|
(py, "-m", "build"): (0, "ok\n"),
|
||||||
@@ -208,7 +233,7 @@ def test_upload_failure_is_9():
|
|||||||
py = publish.PY
|
py = publish.PY
|
||||||
runner = make_runner({
|
runner = make_runner({
|
||||||
("git", "status"): (0, ""),
|
("git", "status"): (0, ""),
|
||||||
("git", "describe"): (0, f"v{version}\n"),
|
("git", "tag", "--points-at"): (0, f"v{version}\n"),
|
||||||
(py, "-m", "build", "--version"): (0, "build\n"),
|
(py, "-m", "build", "--version"): (0, "build\n"),
|
||||||
(py, "-m", "twine", "--version"): (0, "twine\n"),
|
(py, "-m", "twine", "--version"): (0, "twine\n"),
|
||||||
(py, "-m", "build"): (0, "ok\n"),
|
(py, "-m", "build"): (0, "ok\n"),
|
||||||
|
|||||||
Reference in New Issue
Block a user