From 0aa052a17e1a5043fd6dc660caa41645c478bc77 Mon Sep 17 00:00:00 2001 From: Nitload Date: Sat, 1 Mar 2025 05:18:31 +0800 Subject: [PATCH] test commit --- autoadd.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 autoadd.sh diff --git a/autoadd.sh b/autoadd.sh new file mode 100644 index 00000000..0aad5137 --- /dev/null +++ b/autoadd.sh @@ -0,0 +1,58 @@ +#!/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