Phpstorm and pre commit hooks that modify files

2.1k views Asked by At

TLDR: PhpStorm behaves in a weird way when a pre-commit hook modifies a file.


I have this pre-commit hook that checks for modifications on js and css files, and if one of them has been modified, we want the hook to change a configuration file (a file that we use to force a cache reload on all browsers of that "client-side files") so that change would be included in the commit.

The hook looks like this:

#!/bin/bash
JSCSSCHANGE=`git status|grep -E "(.css|.js)"|wc -l`
if [ $JSCSSCHANGE -ne 0 ]; then
  #MODIFY THE FILE
  git add .
fi

The fact is that when we commit through command line or even with SourceTree it works fine: the file it's modified and included in the commit.

But when we make the commit through PhpStorm, after the commit it's done including the modified file, we are left with that same file pending for commit, with modified status. The commit was done perfectly, and it included the modification, but we are left with a the same file in modified status.

1

There are 1 answers

0
MaXal On BEST ANSWER