Phpstorm和预提交钩子修改文件 [英] Phpstorm and pre commit hooks that modify files
问题描述
我有这个预先提交钩子检查js和css文件的修改,如果其中一个已被修改,我们希望钩子更改配置文件(我们用来强制缓存重新加载到该客户端的所有浏览器上的文件
钩子看起来像这样:
<$> p $ p $
JSCSSCHANGE =`git status | grep -E(.css | .js)| wc -l`
if [$ JSCSSCHANGE -ne 0];然后
#MODIFY文件
git add。
fi
事实是,当我们通过命令行或甚至SourceTree进行提交时,罚款:它被修改并包含在提交中的文件。但是,当我们通过PhpStorm进行提交时,在提交完成之后(包括修改后的文件),我们将留下相同的文件,等待提交,状态为已修改。提交完成得很完美,它包含了修改,但是我们留下了一个处于修改状态的相同文件。 解决方案
这是一个已知问题: https://youtrack.jetbrains.com/issue/IDEA-133873
它应该在PhpStorm 8.0.3中修复EAP: http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program
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.
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
这篇关于Phpstorm和预提交钩子修改文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!