Skip to content
Permalink
Browse files

Prevent duplicated link defs in CHANGES.md

  • Loading branch information
dahlia committed Nov 14, 2019
1 parent fd74891 commit 1319215b6463255b13805ca7ed2e1bac048dda14
Showing with 25 additions and 1 deletion.
  1. +0 −1 CHANGES.md
  2. +24 −0 hooks/check-changelog
  3. +1 −0 hooks/pre-commit
@@ -919,7 +919,6 @@ Released on May 31, 2019.
[#187]: https://github.com/planetarium/libplanet/issues/187
[#190]: https://github.com/planetarium/libplanet/pull/190
[#191]: https://github.com/planetarium/libplanet/pull/191
[#192]: https://github.com/planetarium/libplanet/pull/192
[#193]: https://github.com/planetarium/libplanet/pull/193
[#197]: https://github.com/planetarium/libplanet/pull/197
[#198]: https://github.com/planetarium/libplanet/pull/198
@@ -0,0 +1,24 @@
#!/bin/bash
set -e

duplicated_links() {
grep -E '^\[[^]\n]+\]: ' "$1" \
| awk 'BEGIN {FS = ": "}; {print $1}' \
| sort \
| uniq -d
}

if [[ "$(duplicated_links CHANGES.md)" != "" ]]; then
if [[ -t 2 ]]; then
color=always
else
color=never
fi
{
echo "CHANGES.md contains duplicated link definitions:"
duplicated_links CHANGES.md | while read -r link; do
grep --color="$color" -nF "$link" CHANGES.md
done | sed -e 's/^/ /'
} > /dev/stderr
exit 1
fi
@@ -2,5 +2,6 @@
set -e

"$(dirname "$0")/check-bom"
"$(dirname "$0")/check-changelog"

# vim: set filetype=sh ts=2 sw=2 et:

0 comments on commit 1319215

Please sign in to comment.
You can’t perform that action at this time.