1

I created pre-commit hook for my project. It works fine if I commit changes through command line or Git Extensions GUI. But if I commit my changes through Visual studio, for some reason perl command gets somehow ignored, does nothing and output file is the same.

I am trying to delete some lines in .json file if it matches my regex expression. Here is script I am using in pre-commit hook.

for file in $(git diff --cached --name-only)
do
    if [[ $file == "path/to/my/file"* ]]; then
        file="./${file}"
        perl -i -pne 'BEGIN {undef $/} s/^\s*"id":.*?\r?\n//img' $file
        perl -i -pne 'BEGIN {undef $/} s/,(\s*})/$1/isg' $file
        git add $file
    fi
done
Martin Kumecký
  • 175
  • 2
  • 13

1 Answers1

2

It seems that Visual studio has its own implementation of Git, which doesn't have perl command, so it gets ignored. There are 2 possible solutions:

Martin Kumecký
  • 175
  • 2
  • 13