... | ... | @@ -113,52 +113,6 @@ file->settins->搜索 git |
|
|
|
|
|
试试能不能用git了吧~~
|
|
|
|
|
|
### 设置git 的 pre-commit
|
|
|
```
|
|
|
cd 项目目录/web-php/.git/hooks
|
|
|
cp pre-commit.sample pre-commit
|
|
|
|
|
|
注意:先要确定pre-commit是可执行文件,如果不是可执行文件运行:chmod 755 pre-commit
|
|
|
|
|
|
vim pre-commit
|
|
|
|
|
|
将所有内容删除,替换为如下内容:
|
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
# An example hook script to verify what is about to be committed.
|
|
|
# Called by "git commit" with no arguments.
|
|
|
# The hook should exit with non-zero status after issuing an appropriate message if it wants to stop the commit.
|
|
|
# To enable this hook, rename this file to "pre-commit".
|
|
|
# If you really not sure how to do that, you can use '--no-verify' to skip this check
|
|
|
# Like this:git commit -m 'update' --no-verify
|
|
|
|
|
|
|
|
|
|
|
|
#define file or dir
|
|
|
SENSITIVE=(system app-job/run.php app-job/class/bin/Abstract.php app-core/CacheDao.php)
|
|
|
#SENSITIVE=(server)
|
|
|
|
|
|
|
|
|
|
|
|
STAGE_FILES=$(git diff --cached --name-only)
|
|
|
if test ${#STAGE_FILES} -gt 0
|
|
|
then
|
|
|
echo 'Start checking files...'
|
|
|
echo $STAGE_FILES
|
|
|
|
|
|
for FILE in $STAGE_FILES;do
|
|
|
for NOTICE in ${SENSITIVE[@]};do
|
|
|
if [[ "$FILE" =~ "$NOTICE" ]];then
|
|
|
echo 'The commit failed because you modified the file:'$FILE
|
|
|
exit 1
|
|
|
fi
|
|
|
done
|
|
|
done
|
|
|
|
|
|
fi
|
|
|
exit 0
|
|
|
```
|
|
|
|
|
|
|
|
|
|
... | ... | |