| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
| 5 | checker="${repo_root}/scripts/release/check-feature-release-notes.sh" |
| 6 | fixture="$(mktemp -d)" |
| 7 | trap 'rm -rf "${fixture}"' EXIT |
| 8 | |
| 9 | git -C "${fixture}" init -q |
| 10 | git -C "${fixture}" config user.name "Release Test" |
| 11 | git -C "${fixture}" config user.email "release-test@example.com" |
| 12 | mkdir -p "${fixture}/docs" |
| 13 | printf '# Changelog\n' >"${fixture}/CHANGELOG.md" |
| 14 | printf '# Archive\n' >"${fixture}/docs/CHANGELOG_ARCHIVE.md" |
| 15 | git -C "${fixture}" add CHANGELOG.md docs/CHANGELOG_ARCHIVE.md |
| 16 | git -C "${fixture}" commit -qm "chore: seed release notes" |
| 17 | git -C "${fixture}" tag v1.0.0 |
| 18 | |
| 19 | printf 'feature\n' >"${fixture}/feature.txt" |
| 20 | git -C "${fixture}" add feature.txt |
| 21 | git -C "${fixture}" commit -qm "feat(tui): add multiline composer (#123)" |
| 22 | |
| 23 | if RELEASE_NOTE_REPO_ROOT="${fixture}" "${checker}" v1.0.0 HEAD >"${fixture}/missing.out" 2>&1; then |
| 24 | echo "missing feature receipt unexpectedly passed" >&2 |
| 25 | exit 1 |
| 26 | fi |
| 27 | grep -Fq 'references #123, but no release-note receipt exists' "${fixture}/missing.out" |
| 28 | |
| 29 | printf '\n- Multiline composer mode (#123).\n' >>"${fixture}/CHANGELOG.md" |
| 30 | git -C "${fixture}" add CHANGELOG.md |
| 31 | git -C "${fixture}" commit -qm "docs: record multiline composer" |
| 32 | RELEASE_NOTE_REPO_ROOT="${fixture}" "${checker}" v1.0.0 HEAD >"${fixture}/present.out" |
| 33 | grep -Fq '1 linked issue reference(s) checked' "${fixture}/present.out" |
| 34 | |
| 35 | printf 'color\n' >"${fixture}/color.txt" |
| 36 | git -C "${fixture}" add color.txt |
| 37 | git -C "${fixture}" commit -qm 'feat(tui): use brand cyan #48D7FF' |
| 38 | RELEASE_NOTE_REPO_ROOT="${fixture}" "${checker}" v1.0.0 HEAD >"${fixture}/color.out" |
| 39 | grep -Fq '1 linked issue reference(s) checked' "${fixture}/color.out" |
| 40 | |
| 41 | printf 'reconciled\n' >"${fixture}/reconciled.txt" |
| 42 | git -C "${fixture}" add reconciled.txt |
| 43 | git -C "${fixture}" commit -qm 'feat(tui): reconcile earlier feature (#456)' |
| 44 | printf '\n- Earlier release already recorded this feature (#456).\n' >>"${fixture}/docs/CHANGELOG_ARCHIVE.md" |
| 45 | RELEASE_NOTE_REPO_ROOT="${fixture}" "${checker}" v1.0.0 HEAD >"${fixture}/archive.out" |
| 46 | grep -Fq '2 linked issue reference(s) checked' "${fixture}/archive.out" |
| 47 | |
| 48 | echo "check-feature-release-notes tests passed" |
| 49 |