【测试】Hook 测试提交
parent
ae8e5cabd7
commit
b0deb44a15
|
@ -15,6 +15,9 @@ using Object = UnityEngine.Object;
|
|||
using Vector3 = UnityEngine.Vector3;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
|
||||
namespace Gameplay.Level
|
||||
{
|
||||
public class LevelState : IState
|
||||
|
|
|
@ -1,34 +1,37 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "执行pre-commit钩子"
|
||||
echo "执行 pre-commit 钩子"
|
||||
|
||||
check_commit() {
|
||||
# 执行检查
|
||||
git diff --cached --name-only | while read FILE; do
|
||||
echo "检查文件: $FILE"
|
||||
if [[ "$FILE" =~ \.cs$ ]]; then
|
||||
git diff --cached --unified=0 "$FILE" | grep -v '^-' | grep -q "Forbidden to commit"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "提交失败: $FILE 包含'Forbidden to commit'内容"
|
||||
return 1
|
||||
# 检查 'Forbidden to commit' 字样
|
||||
if git diff --cached --unified=0 -- "$FILE" | grep -v '^-' | grep -q "Forbidden to commit"; then
|
||||
echo "提交失败: $FILE 包含 'Forbidden to commit' 内容"
|
||||
exit 1
|
||||
fi
|
||||
# 只对Code文件夹下的文件进行检查
|
||||
|
||||
# 仅对 'Forest/Assets/Scripts/' 路径下的文件进行额外检查
|
||||
if [[ $FILE == *"Forest/Assets/Scripts/"* ]]; then
|
||||
git diff --cached --unified=0 "$FILE" | grep -v '^-' | grep -q "using NPOI.SS.Formula.Functions"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Code 提交失败: $FILE 包含'using NPOI.SS.Formula.Functions'内容"
|
||||
return 1
|
||||
if git diff --cached --unified=0 -- "$FILE" | grep -v '^-' | grep -q "using NPOI.SS.Formula.Functions"; then
|
||||
echo "Code 提交失败: $FILE 包含 'using NPOI.SS.Formula.Functions' 内容"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 执行检查函数
|
||||
check_commit
|
||||
|
||||
# 检查是否通过
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "pre-commit 检查失败,取消commit"
|
||||
echo "pre-commit 检查失败,取消 commit"
|
||||
exit 1
|
||||
else
|
||||
echo "pre-commit 检查成功,允许commit"
|
||||
echo "pre-commit 检查成功,允许 commit"
|
||||
exit 0
|
||||
fi
|
Loading…
Reference in New Issue