2026-07-22 18:38:35 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
|
# shellcheck source=lib/changelog.sh
|
|
|
|
|
source "$ROOT/lib/changelog.sh"
|
|
|
|
|
|
2026-07-22 18:56:25 +00:00
|
|
|
ver="${1:-}"
|
|
|
|
|
changelog="${2:-CHANGELOG.md}"
|
|
|
|
|
if [ -z "$ver" ]; then
|
|
|
|
|
echo "usage: changelog-section <version> [<changelog>]" >&2
|
2026-07-22 18:38:35 +00:00
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
[ -f "$changelog" ] || {
|
|
|
|
|
echo "changelog-section: no such file: $changelog" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-23 23:42:31 +00:00
|
|
|
if ! diagnosis="$(changelog_section_problem "$changelog" "$ver")"; then
|
2026-07-22 18:38:35 +00:00
|
|
|
echo "changelog-section: $changelog has no section for '$ver' — the release PR stamps the Unreleased section with version + date BEFORE the tag" >&2
|
2026-07-23 23:42:31 +00:00
|
|
|
printf 'changelog-section: %s\n' "$diagnosis" >&2
|
2026-07-22 18:38:35 +00:00
|
|
|
exit 1
|
2026-07-23 23:42:31 +00:00
|
|
|
fi
|
|
|
|
|
notes="$(changelog_section "$changelog" "$ver")"
|
2026-07-22 18:38:35 +00:00
|
|
|
printf '%s\n' "$notes"
|