Skip to content

Commit

Permalink
Check for credentials before every commit
Browse files Browse the repository at this point in the history
In order to use, it cred-alert needs to be installed.
Also, we enable the usage of rubocop.

Co-authored-by: David Ansari <david.ansari@sap.com>
  • Loading branch information
Max Becker and ansd committed Feb 28, 2019
1 parent 0846cb3 commit 1bc0989
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .envrc
@@ -0,0 +1,5 @@
#!/bin/bash

if [ ! -f $PWD/.git/hooks/pre-commit ]; then
ln -s $PWD/git-hooks/pre-commit $PWD/.git/hooks/pre-commit
fi
15 changes: 15 additions & 0 deletions git-hooks/pre-commit
@@ -1,2 +1,17 @@
#!/bin/bash

set -euo pipefail

RED='\033[0;35m'
NC='\033[0m' # No Color

if hash cred-alert-cli 2>/dev/null; then
CMD="git diff --cached | cred-alert-cli scan --diff"
echo "Running '${CMD}'"
eval "$CMD"
else
>&2 echo -e "${RED}Not checking whether credentials get committed. cred-alert-cli is not installed.${NC}"
fi

unset GIT_DIR
scripts/rubocop-staged

0 comments on commit 1bc0989

Please sign in to comment.