Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .mise/scripts/check-release
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,18 @@ section=$(awk -v h="## [$version]" '
[[ -n "${section//[[:space:]]/}" ]] || fail "CHANGELOG.md has no filled '## [$version]' section"

((failures == 0)) || exit 1
$notes && printf '%s\n' "$section"

# The changelog is wrapped for the repository; a release page is not, so a
# bullet's continuation lines are joined onto it. Relative links would lead
# nowhere from the release page, so they point at the tag when the repository
# is known, as it is on a runner.
if $notes; then
base=""
[[ -z "${GITHUB_REPOSITORY:-}" ]] || base="${GITHUB_SERVER_URL:-https://github.com}/$GITHUB_REPOSITORY/blob/$tag/"
printf '%s\n' "$section" | awk '
/^ / { sub(/^ +/, ""); line = line " " $0; next }
{ if (NR > 1) print line; line = $0 }
END { print line }
' | sed -E "s|\]\(|](${base}|g; s|\]\(${base}(https?://)|](\1|g"
fi
exit 0
26 changes: 24 additions & 2 deletions tests/unit/test_check_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def make_repo(root: Path, *, skill: str = "0.1.0", pyproject: str = "0.1.0") ->
)


def run(root: Path, *args: str) -> subprocess.CompletedProcess[str]:
def run(root: Path, *args: str, **env: str) -> subprocess.CompletedProcess[str]:
return subprocess.run( # noqa: S603
["bash", str(SCRIPT), *args], # noqa: S607
capture_output=True,
text=True,
check=False,
env={"CHECK_RELEASE_ROOT": str(root), "PATH": "/usr/bin:/bin"},
env={"CHECK_RELEASE_ROOT": str(root), "PATH": "/usr/bin:/bin", **env},
)


Expand All @@ -60,6 +60,28 @@ def test_notes_are_the_matching_section_only(tmp_path: Path) -> None:
assert result.stdout.strip() == "- First release.\n- Second line."


def test_notes_join_wrapped_lines_and_point_links_at_the_tag(tmp_path: Path) -> None:
# Given a changelog whose bullet wraps and links to a file in the repository
make_repo(tmp_path)
(tmp_path / "CHANGELOG.md").write_text(
"# Changelog\n\n## [0.1.0] - 2026-10-02\n\n"
"- First release, wrapped\n onto a second line ([ADR](docs/a.md), [site](https://x.test/y)).\n"
"- Second.\n"
)

# When the notes are asked for on a runner, which names its repository
result = run(tmp_path, "v0.1.0", "--notes", GITHUB_REPOSITORY="org/repo")

# Then each bullet is one line, and only the relative link is rewritten
assert result.stdout.strip().splitlines() == [
(
"- First release, wrapped onto a second line "
"([ADR](https://github.com/org/repo/blob/v0.1.0/docs/a.md), [site](https://x.test/y))."
),
"- Second.",
]


@pytest.mark.parametrize("tag", ["0.1.0", "v1", "v0.1", "v0.1.0-rc1", ""])
def test_malformed_tag_is_a_usage_error(tmp_path: Path, tag: str) -> None:
# Given a consistent repository
Expand Down
Loading