Fix case repo sync + auto-create Gitea repos + add sync indicator
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m30s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m30s
- auto-sync-cases.sh: fix broken directory scan (was looking for
status subdirs that don't exist), fix env var word-splitting bug,
add safe.directory handling and error logging
- cases.py: auto-create Gitea repo on case_create, fix
documents/original → documents/originals naming mismatch
- app.py: add GET /api/cases/{case_number}/git-status endpoint
- web-ui: add SyncIndicator component in case header showing
sync status (synced/pending/no remote) with last commit time
- pyproject.toml: add httpx dependency
- CLAUDE.md: update Paperclip wakeup API docs
- settings page: switch tag input from Select to free-text with datalist
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,34 +4,50 @@
|
||||
|
||||
CASES_DIR="/home/chaim/legal-ai/data/cases"
|
||||
LOG="/home/chaim/legal-ai/data/.auto-sync.log"
|
||||
GIT_ENV="GIT_AUTHOR_NAME=Ezer Mishpati GIT_AUTHOR_EMAIL=legal@local GIT_COMMITTER_NAME=Ezer Mishpati GIT_COMMITTER_EMAIL=legal@local GIT_TERMINAL_PROMPT=0"
|
||||
|
||||
for status_dir in "$CASES_DIR"/new "$CASES_DIR"/in-progress "$CASES_DIR"/completed; do
|
||||
[ -d "$status_dir" ] || continue
|
||||
for case_dir in "$status_dir"/*/; do
|
||||
[ -d "$case_dir/.git" ] || continue
|
||||
export GIT_AUTHOR_NAME="Ezer Mishpati"
|
||||
export GIT_AUTHOR_EMAIL="legal@local"
|
||||
export GIT_COMMITTER_NAME="Ezer Mishpati"
|
||||
export GIT_COMMITTER_EMAIL="legal@local"
|
||||
export GIT_TERMINAL_PROMPT=0
|
||||
|
||||
cd "$case_dir" || continue
|
||||
for case_dir in "$CASES_DIR"/*/; do
|
||||
[ -d "$case_dir/.git" ] || continue
|
||||
|
||||
# Check for any changes (modified, new, deleted)
|
||||
changes=$(git status --porcelain 2>/dev/null)
|
||||
[ -z "$changes" ] && continue
|
||||
case_name=$(basename "$case_dir")
|
||||
|
||||
# Stage all changes
|
||||
git add -A 2>/dev/null
|
||||
# Ensure safe.directory is set for this repo
|
||||
git config --global --get-all safe.directory | grep -qF "$case_dir" \
|
||||
|| git config --global --add safe.directory "$case_dir"
|
||||
|
||||
# Build commit message from changed files
|
||||
changed_files=$(git diff --cached --name-only 2>/dev/null | head -5)
|
||||
count=$(git diff --cached --name-only 2>/dev/null | wc -l)
|
||||
case_name=$(basename "$case_dir")
|
||||
msg="סנכרון אוטומטי — ${count} קבצים שונו"
|
||||
cd "$case_dir" || continue
|
||||
|
||||
# Commit
|
||||
env $GIT_ENV git commit -m "$msg" --quiet 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# Push (non-blocking, ignore errors)
|
||||
git push origin main --quiet 2>/dev/null
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | $count files synced" >> "$LOG"
|
||||
# Check for any changes (modified, new, deleted)
|
||||
changes=$(git status --porcelain 2>/dev/null)
|
||||
[ -z "$changes" ] && continue
|
||||
|
||||
# Stage all changes
|
||||
git add -A 2>/dev/null
|
||||
|
||||
# Count changed files
|
||||
count=$(git diff --cached --name-only 2>/dev/null | wc -l)
|
||||
[ "$count" -eq 0 ] && continue
|
||||
|
||||
msg="סנכרון אוטומטי — ${count} קבצים שונו"
|
||||
|
||||
# Commit
|
||||
if git commit -m "$msg" --quiet 2>/dev/null; then
|
||||
# Push only if remote exists
|
||||
if git remote get-url origin >/dev/null 2>&1; then
|
||||
if git push origin HEAD --quiet 2>/dev/null; then
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | $count files synced + pushed" >> "$LOG"
|
||||
else
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | $count files committed, push FAILED" >> "$LOG"
|
||||
fi
|
||||
else
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | $count files committed (no remote)" >> "$LOG"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | commit FAILED" >> "$LOG"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user