Add pre-commit check for changelog fragment placement
Misfiled fragment from feature/ branch created a subdirectory under changelog.d/ which towncrier doesn't support. Move the fragment to the correct flat location and add a changelog-check mise task + prek hook to prevent this from happening again. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
01d3b4d1c7
commit
6c5a99883f
4 changed files with 39 additions and 0 deletions
1
docs/changelog.d/main.infra.md
Normal file
1
docs/changelog.d/main.infra.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add pre-commit hook to prevent changelog fragments from being placed in subdirectories.
|
||||||
26
mise-tasks/changelog-check
Executable file
26
mise-tasks/changelog-check
Executable file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#MISE description="Validate changelog fragments are flat files in docs/changelog.d/"
|
||||||
|
# Ensures no fragments end up in subdirectories (e.g. from branch names like feature/foo).
|
||||||
|
# Towncrier expects flat <name>.<type>.md files, not nested paths.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
CHANGELOG_DIR="$(git rev-parse --show-toplevel)/docs/changelog.d"
|
||||||
|
|
||||||
|
errors=0
|
||||||
|
while IFS= read -r -d '' entry; do
|
||||||
|
rel="${entry#"$CHANGELOG_DIR/"}"
|
||||||
|
if [[ "$rel" == */* ]]; then
|
||||||
|
echo "ERROR: changelog fragment in subdirectory: docs/changelog.d/$rel"
|
||||||
|
echo " Move to: docs/changelog.d/$(echo "$rel" | tr '/' '-')"
|
||||||
|
errors=$((errors + 1))
|
||||||
|
fi
|
||||||
|
done < <(find "$CHANGELOG_DIR" -name '*.md' -print0)
|
||||||
|
|
||||||
|
if [ "$errors" -gt 0 ]; then
|
||||||
|
echo ""
|
||||||
|
echo "$errors fragment(s) in subdirectories. Towncrier requires flat files in docs/changelog.d/."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "All changelog fragments are correctly placed."
|
||||||
12
prek.toml
12
prek.toml
|
|
@ -120,6 +120,18 @@ language = "system"
|
||||||
files = "^(containers/|service-versions\\.yaml)"
|
files = "^(containers/|service-versions\\.yaml)"
|
||||||
pass_filenames = false
|
pass_filenames = false
|
||||||
|
|
||||||
|
# Changelog fragment validation (no subdirectories)
|
||||||
|
[[repos]]
|
||||||
|
repo = "local"
|
||||||
|
|
||||||
|
[[repos.hooks]]
|
||||||
|
id = "changelog-check"
|
||||||
|
name = "changelog-check"
|
||||||
|
entry = "mise run changelog-check"
|
||||||
|
language = "system"
|
||||||
|
files = '^docs/changelog\.d/'
|
||||||
|
pass_filenames = false
|
||||||
|
|
||||||
# Mikado Branch Invariant (C2 changes)
|
# Mikado Branch Invariant (C2 changes)
|
||||||
[[repos]]
|
[[repos]]
|
||||||
repo = "local"
|
repo = "local"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue