mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Refactored output of git hooks
This commit is contained in:
parent
c59d776031
commit
5b92b29dc4
@ -25,6 +25,6 @@ CHANGED="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
|
|||||||
|
|
||||||
# Perform install and prune of NPM dependencies if package.json changed
|
# Perform install and prune of NPM dependencies if package.json changed
|
||||||
if $(echo "$CHANGED" | grep --quiet package.json); then
|
if $(echo "$CHANGED" | grep --quiet package.json); then
|
||||||
echo "Hook[post-merge]: Updating dependencies"
|
echo -e "\x1B[33m!\x1B[0m Updating dependencies"
|
||||||
npm install && npm prune
|
npm install && npm prune
|
||||||
fi
|
fi
|
||||||
|
@ -22,12 +22,14 @@
|
|||||||
|
|
||||||
# Determine current branch
|
# Determine current branch
|
||||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
echo "Hook[pre-commit]: Checking branch"
|
MESSAGE="Commits on master are only allowed via Pull Requests. Aborting."
|
||||||
|
|
||||||
# If we're on master, abort commit
|
# If we're on master, abort commit
|
||||||
if [[ "$BRANCH" == "master" ]]; then
|
if [[ "$BRANCH" == "master" ]]; then
|
||||||
echo "Commits on master are only allowed via Pull Requests. Aborting."
|
echo -e "\x1B[31m✗\x1B[0m Branch: $BRANCH - \x1B[31m$MESSAGE\x1B[0m"
|
||||||
exit 1
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "\x1B[32m✓\x1B[0m Branch: $BRANCH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We're good
|
# We're good
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
# Patch file to store unindexed changes
|
# Patch file to store unindexed changes
|
||||||
PATCH_FILE=".working-tree.patch"
|
PATCH_FILE=".working-tree.patch"
|
||||||
|
MESSAGE="Terminated with errors"
|
||||||
|
|
||||||
# Revert changes that have been registered in the patch file
|
# Revert changes that have been registered in the patch file
|
||||||
function cleanup {
|
function cleanup {
|
||||||
@ -46,6 +47,16 @@ FILES=$(git diff --cached --name-only --diff-filter=ACMR | \
|
|||||||
|
|
||||||
# Run the check and print indicator
|
# Run the check and print indicator
|
||||||
if [ "$FILES" ]; then
|
if [ "$FILES" ]; then
|
||||||
echo "Hook[pre-commit]: Running linter"
|
npm run lint --silent
|
||||||
npm run lint --silent || exit 1
|
|
||||||
|
# If we're on master, abort commit
|
||||||
|
if [ $? -gt 0 ]; then
|
||||||
|
echo -e "\x1B[31m✗\x1B[0m Linter - \x1B[31m$MESSAGE\x1B[0m"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "\x1B[32m✓\x1B[0m Linter"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# We're good
|
||||||
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user