You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.2 KiB
Plaintext

#!/bin/sh
# 获取当前项目路径
currentpath=$(pwd)
#获取当前.git路径
git_dir=$(git rev-parse --git-dir)
#获取hooks路径
hooks_dir="$git_dir/hooks"
#.......................................................
#获取bat
bat_dir="$hooks_dir/AutomaticCompilation.bat"
# 执行代码检查
echo "$bat_dir"
#执行AutomaticCompilation.bat脚本
"$bat_dir"
#获取返回值
exitCodeDir="$?"
#判断是否为0正常
if [ "$exitCodeDir" -eq 0 ];then
echo "编译成功$exitCodeDir"
elif [ "$exitCodeDir" -eq 2 ];then
echo "当前文件夹中没有工程!!!"
else
echo "编译失败$exitCodeDir"
echo "请查看$currentpath/msbuild.err文件有部分代码编译问题"
exit 1
fi
#.........................................................
#获取git状态
data=$(git status -uall)
#输出到文件
echo "$data" > gitStatus.txt
#获取TaskCommitFile.exe路径
taskCommitPath="$hooks_dir/TaskCommitFile.exe"
#执行程序
"$taskCommitPath" gitStatus.txt 3
#获取返回值
exitCode="$?"
#删除gitStatus.txt文件
rm gitStatus.txt
#判断是否为2
if [ "$exitCode" -ne 0 ];then
echo "请查看$currentpath/NeedCommit.txt"
echo "请全部提交之后在推送!!!"
exit 1
fi
rm NeedCommit.txt
exit 0