问题
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:
It's a known issue: https://youtrack.jetbrains.com/issue/IDEA-133873
It should be fixed in PhpStorm 8.0.3 EAP: http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program
来源:https://stackoverflow.com/questions/26931103/phpstorm-and-pre-commit-hooks-that-modify-files