Files
omni-parse/tools/autocommit.sh

51 lines
1.7 KiB
Bash
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.

#!/usr/bin/env bash
# Автоцикл: самоаудит -> (опц.) подкачка источников -> коммит изменений -> пуш в Gitea и GitHub.
# Использование: bash tools/autocommit.sh [--feed] [--quiet]
set -uo pipefail
cd "$(dirname "$0")/.." || exit 1
PY="/c/Users/User/AppData/Local/Programs/Python/Python311/python.exe"
FEED=0
for a in "$@"; do [ "$a" = "--feed" ] && FEED=1; done
export PYTHONIOENCODING=utf-8
unset PYTHONPATH
STAMP="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
LOG="data/autocommit.log"
mkdir -p data
echo "== $STAMP ==" >> "$LOG"
# 1) подкачка новых записей (необязательно)
if [ "$FEED" = "1" ]; then
"$PY" -m omni feed --limit 8 --workers 6 >> "$LOG" 2>&1
echo "feed_exit=$?" >> "$LOG"
fi
# 2) самоаудит + REPORT.md
OUT="$("$PY" tools/selfcheck.py 2>&1)"
echo "$OUT" >> "$LOG"
echo "selfcheck_exit=$?" >> "$LOG"
STATS="$(printf '%s
' "$OUT" | tail -1)"
# 3) коммит, только если есть реальные изменения кода/отчёта
git add -A
if git diff --cached --quiet; then
echo "no_changes" >> "$LOG"
exit 0
fi
git commit -q -m "chore(auto): $STAMP — $(printf '%s' "$STATS" | cut -c1-180)"
COMMIT="$(git rev-parse --short HEAD)"
echo "commit=$COMMIT" >> "$LOG"
# 4) пуш в оба ремоута
if git push -q gitea main >> "$LOG" 2>&1; then echo "gitea=OK" >> "$LOG"; else echo "gitea=FAIL" >> "$LOG"; fi
if [ -x /c/Users/User/tmp/push_omni_gh.sh ] || [ -f /c/Users/User/tmp/push_omni_gh.sh ]; then
if bash /c/Users/User/tmp/push_omni_gh.sh >> "$LOG" 2>&1; then echo "github=OK" >> "$LOG"; else echo "github=FAIL" >> "$LOG"; fi
fi
echo "done $COMMIT" >> "$LOG"
echo "autocommit $COMMIT"