49 lines
1.0 KiB
Bash
Executable File
49 lines
1.0 KiB
Bash
Executable File
#!/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 "已恢复 .gitignore,result/ 重新纳入版本控制"
|
||
fi
|
||
|
||
echo "Git push 完成"
|