myTestFreqAI/tools/gitpush.sh
zhangkun9038@dingtalk.com 40911f603c update
2025-05-14 04:58:31 +00:00

49 lines
1.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
#!/bin/bash
# 默认提交信息
commit_msg="update"
# 解析命令行参数 -m 指定提交信息
while getopts m: option; do
case "${option}" in
m) commit_msg=${OPTARG} ;;
esac
done
cd ..
# 检查 result/ 是否已经在 .gitignore 中
IGNORED=$(grep -c "^result/" .gitignore)
# 创建标志文件路径
LOCK_FILE=".gitignore.lock"
# 如果 result/ 不在 .gitignore 中,则临时加入,并记录
if [ "$IGNORED" -eq 0 ]; then
echo "result/" >>.gitignore
echo "已临时将 result/ 添加到 .gitignore"
touch $LOCK_FILE
else
echo "result/ 已经在 .gitignore 中,跳过处理"
fi
rm output*.log
# 停止当前可能存在的交易进程(可选)
# pkill -f "freqtrade trade" || true
# 执行 Git 操作
git add .
git commit --no-verify -m "$commit_msg"
git push
# 如果之前临时加入了 result/ 到 .gitignore则现在恢复
if [ -f "$LOCK_FILE" ]; then
sed -i '/^result\//d' .gitignore
rm -f $LOCK_FILE
echo "已恢复 .gitignoreresult/ 重新纳入版本控制"
fi
echo "Git push 完成"