diff --git a/.githooks/post-merge/npm-update.sh b/.githooks/post-merge/npm-update.sh index cc63394ee..035401427 100755 --- a/.githooks/post-merge/npm-update.sh +++ b/.githooks/post-merge/npm-update.sh @@ -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 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 fi diff --git a/.githooks/pre-commit/branch.sh b/.githooks/pre-commit/branch.sh index 7907e9e43..72f6f1773 100755 --- a/.githooks/pre-commit/branch.sh +++ b/.githooks/pre-commit/branch.sh @@ -22,12 +22,14 @@ # Determine current branch 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 [[ "$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 +else + echo -e "\x1B[32m✓\x1B[0m Branch: $BRANCH" fi # We're good diff --git a/.githooks/pre-commit/lint.sh b/.githooks/pre-commit/lint.sh index 502620ecc..8df754624 100755 --- a/.githooks/pre-commit/lint.sh +++ b/.githooks/pre-commit/lint.sh @@ -22,6 +22,7 @@ # Patch file to store unindexed changes PATCH_FILE=".working-tree.patch" +MESSAGE="Terminated with errors" # Revert changes that have been registered in the patch file function cleanup { @@ -46,6 +47,16 @@ FILES=$(git diff --cached --name-only --diff-filter=ACMR | \ # Run the check and print indicator if [ "$FILES" ]; then - echo "Hook[pre-commit]: Running linter" - npm run lint --silent || exit 1 + npm run lint --silent + + # 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 + +# We're good +exit 0