diff --git a/Makefile b/Makefile index 87201c6..cc6ecab 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL := /bin/bash .PHONY: precommit -precommit: check-links check-json +precommit: check-links check-json check-index .PHONY: release-check release-check: precommit check-versions @@ -26,3 +26,15 @@ check-versions: build-index: @python3 scripts/build-index.py > rules/index.json @echo "rules/index.json updated" + +.PHONY: check-index +check-index: + @python3 scripts/build-index.py > /tmp/coding-rules-index-check.json + @if ! diff -q rules/index.json /tmp/coding-rules-index-check.json > /dev/null 2>&1; then \ + echo "ERROR: rules/index.json is stale. Run 'make build-index' and commit the result."; \ + diff -u rules/index.json /tmp/coding-rules-index-check.json | head -40; \ + rm -f /tmp/coding-rules-index-check.json; \ + exit 1; \ + fi + @rm -f /tmp/coding-rules-index-check.json + @echo "rules/index.json up-to-date"