Skip to content

Commit

Permalink
Fix: git add bug (#300)
Browse files Browse the repository at this point in the history
* Fix git add bug

* Amend fix
  • Loading branch information
arifulhaqueHO authored Oct 12, 2022
1 parent e37ba83 commit 9730195
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .githooks/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ set -e

JSONNET_FILES_CHANGED=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep "sonnet" | wc -l)
DOCKERFILE_CHANGED=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep "Dockerfile" | wc -l)
SHELL_FILE_CHANGED=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep ".sh" | wc -l)
SHELL_FILE_CHANGED=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep -E ".sh$" | wc -l)
MD_FILES_CHANGED=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep -E ".md|.md.erb" | wc -l)

REPO_ROOT_DIR=$(git rev-parse --show-toplevel)

if [ "$JSONNET_FILES_CHANGED" -gt "0" ]; then
$REPO_ROOT_DIR/monitoring-as-code/fmt.sh
$REPO_ROOT_DIR/monitoring-as-code/lint.sh
git add $REPO_ROOT_DIR
git add $(git diff --name-only --cached)
fi

if [ "$DOCKERFILE_CHANGED" -gt "0" ]; then
Expand All @@ -24,7 +24,7 @@ if [ "$DOCKERFILE_CHANGED" -gt "0" ]; then
fi

if [ "$SHELL_FILE_CHANGED" -gt "0" ]; then
shell_files=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep ".sh")
shell_files=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep -E ".sh$")
for shell_file in $shell_files
do
echo $shell_file | xargs docker run --rm -v "$REPO_ROOT_DIR:/mnt" koalaman/shellcheck:stable
Expand Down

0 comments on commit 9730195

Please sign in to comment.