| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #!/bin/bash
- # ============================================================
- # PlateRecApp 自动同步到 Gogs 仓库
- # 仓库: https://git.zhonjin.com:40717/steven_roc/PlateRecApp
- # ============================================================
- set -e
- REPO_URL="https://steven_roc:1942ce3d6478f7a572fee3dd4891e49f6c416aad@git.zhonjin.com:40717/steven_roc/PlateRecApp.git"
- WORK_DIR="/opt/openAI/project/003.PlateRecAPP"
- COMMIT_MSG="${1:-auto sync: $(date '+%Y-%m-%d %H:%M:%S')}"
- echo "=========================================="
- echo " PlateRecApp -> Gogs 自动同步"
- echo " 时间: $(date '+%Y-%m-%d %H:%M:%S')"
- echo "=========================================="
- # 检查是否在源码目录
- if [ ! -f "$WORK_DIR/CMakeLists.txt" ]; then
- echo "错误: 未找到 $WORK_DIR/CMakeLists.txt"
- echo "请确认源码目录路径正确"
- exit 1
- fi
- cd "$WORK_DIR"
- # 初始化 git(首次)
- if [ ! -d ".git" ]; then
- echo "[1/4] 初始化 Git 仓库..."
- git init
- git remote add origin "$REPO_URL" 2>/dev/null || git remote set-url origin "$REPO_URL"
- git checkout -b master
-
- # 配置 git
- git config user.email "steven_roc@126.com"
- git config user.name "steven_roc"
-
- # 创建 .gitignore
- cat > .gitignore << 'EOF'
- # 编译产物
- build/
- *.o
- *.obj
- *.exe
- PlateRecApp
- # 配置文件(含敏感信息)
- config.ini
- config_*.ini
- # 日志
- *.log
- logs/
- # 数据库
- *.db
- *.sqlite
- # 临时文件
- *.tmp
- *.bak
- *.swp
- *~
- # 系统文件
- .DS_Store
- Thumbs.db
- # IDE
- .vscode/
- .idea/
- *.suo
- *.user
- EOF
-
- echo "[2/4] 首次提交..."
- git add -A
- git commit -m "init: PlateRecApp fix27 v44 完整代码初始化"
- else
- echo "[1/4] Git 仓库已存在"
- echo "[2/4] 检查变更..."
-
- git config user.email "steven_roc@126.com"
- git config user.name "steven_roc"
-
- CHANGES=$(git status --porcelain | wc -l)
- if [ "$CHANGES" -eq 0 ]; then
- echo "没有检测到代码变更,跳过同步"
- exit 0
- fi
- echo "检测到 $CHANGES 个文件变更"
-
- git add -A
- git commit -m "$COMMIT_MSG"
- fi
- echo "[3/4] 推送到 Gogs..."
- git push -u origin master --force
- echo "[4/4] 同步完成!"
- echo ""
- echo "仓库地址: https://git.zhonjin.com:40717/steven_roc/PlateRecApp"
- echo "同步时间: $(date '+%Y-%m-%d %H:%M:%S')"
- echo "=========================================="
|