57 lines
1.3 KiB
Bash
57 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
clear
|
|
|
|
# 设置要查找的文件类型
|
|
file_types=( "*.cs" "*.c" "*.cpp" "*.h" "*.txt" "*.csproj" "*.vs" "*.vert" "*.frag" "*.sln" "*.vcxproj" "*.json" "*.sh" )
|
|
|
|
# 循环遍历每个文件类型,并添加到git
|
|
for type in "${file_types[@]}"; do
|
|
# 执行find命令,并将输出保存到变量中
|
|
add_output=$(find . -name "$type" -exec git add '{}' + 2>&1)
|
|
add_status=$?
|
|
|
|
# 检查find命令的退出状态
|
|
if [ $add_status -ne 0 ]; then
|
|
# 如果出错,显示保存的输出
|
|
echo "$add_output"
|
|
exit 1
|
|
fi
|
|
done
|
|
clear
|
|
|
|
# 提示用户输入commit信息
|
|
echo "====================== file added ======================"
|
|
echo "请输入commit信息:"
|
|
read commit_message
|
|
|
|
# 执行git commit命令,并将输出保存到变量中
|
|
commit_output=$(git commit -m "$commit_message" 2>&1)
|
|
commit_status=$?
|
|
|
|
# 检查git commit命令的退出状态
|
|
if [ $commit_status -ne 0 ]; then
|
|
# 如果出错,显示保存的输出
|
|
echo "$commit_output"
|
|
exit 1
|
|
fi
|
|
|
|
clear
|
|
|
|
echo ""
|
|
echo "================ successfully committed ================="
|
|
echo ""
|
|
# 执行git push命令
|
|
git push CCD_Git local:main
|
|
git push CCD_Git local:nitload
|
|
|
|
if [ $? -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "Successfully pushed, press enter to quit"
|
|
read commit_message
|
|
|
|
clear
|
|
exit |