mirror of
https://github.com/Azure/setup-kubectl.git
synced 2026-05-22 17:02:04 +00:00
add version sync check to pre-commit hook
This commit is contained in:
parent
957433fc96
commit
fbbecfa05f
1 changed files with 25 additions and 2 deletions
|
|
@ -1,9 +1,32 @@
|
||||||
set +e
|
set +e
|
||||||
npm test
|
npm test
|
||||||
# Run format check
|
|
||||||
npm run format-check || {
|
npm run format-check || {
|
||||||
echo ""
|
echo ""
|
||||||
echo "❌ Formatting check failed."
|
echo "❌ Formatting check failed."
|
||||||
echo "💡 Run 'npm run format' or 'prettier --write .' to fix formatting issues."
|
echo "💡 Run 'npm run format' or 'prettier --write .' to fix formatting issues."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STAGED=$(git diff --cached --name-only)
|
||||||
|
if echo "$STAGED" | grep -qE '^(package\.json|package-lock\.json|CHANGELOG\.md)$'; then
|
||||||
|
PKG_VERSION=$(node -p "require('./package.json').version")
|
||||||
|
LOCK_VERSION=$(node -p "require('./package-lock.json').version")
|
||||||
|
CHANGELOG_VERSION=$(sed -n 's/^## \[\([^]]*\)\].*/\1/p' CHANGELOG.md | head -1)
|
||||||
|
|
||||||
|
MISMATCH=""
|
||||||
|
if [ "$PKG_VERSION" != "$LOCK_VERSION" ]; then
|
||||||
|
MISMATCH="${MISMATCH}\n package.json: ${PKG_VERSION}\n package-lock.json: ${LOCK_VERSION}"
|
||||||
|
fi
|
||||||
|
if [ "$PKG_VERSION" != "$CHANGELOG_VERSION" ]; then
|
||||||
|
MISMATCH="${MISMATCH}\n package.json: ${PKG_VERSION}\n CHANGELOG.md: ${CHANGELOG_VERSION}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$MISMATCH" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "❌ Version mismatch detected:"
|
||||||
|
echo -e "$MISMATCH"
|
||||||
|
echo ""
|
||||||
|
echo "💡 Ensure package.json, package-lock.json, and CHANGELOG.md all have the same version."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue