Skip to content

Commit

Permalink
Merge pull request #6 from ZeekInteractive/githook-precommit-update
Browse files Browse the repository at this point in the history
update precommit hook
  • Loading branch information
jmwamser authored Jul 17, 2024
2 parents 11137f4 + 0c21f6c commit 40a2da5
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion templates/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,22 @@
export PATH=$PATH:/usr/local/bin:/opt/homebrew/bin

set -e

# Initial cache of files
INIT_FILES=$(git diff --name-only --cached)

# Run Make file
make precommit
git add .

# Get the list of modified files after running php-cs-fixer
MODIFIED_FILES=$(git diff --name-only --cached)

# Compare the new list to the original list and add the matching files to the staging area
for file in $MODIFIED_FILES; do
for init_file in $INIT_FILES; do
if [ "$file" = "$init_file" ] && [ -e "$file" ]; then
git add "$file"
break
fi
done
done

0 comments on commit 40a2da5

Please sign in to comment.