FossilRepo
| 45192ef… | ragelink | 1 | #!/bin/bash |
| 45192ef… | ragelink | 2 | # sync_to_fossil.sh — Commit current code into the existing .fossil repo. |
| 45192ef… | ragelink | 3 | # |
| 45192ef… | ragelink | 4 | # Opens a temporary checkout, rsyncs the working tree in, commits changes. |
| 45192ef… | ragelink | 5 | # NEVER replaces or reimports the .fossil file — preserves all tickets, |
| 45192ef… | ragelink | 6 | # wiki, forum, and other Fossil-native artifacts. |
| 45192ef… | ragelink | 7 | # |
| 45192ef… | ragelink | 8 | # Usage: ./scripts/sync_to_fossil.sh ["commit message"] |
| 45192ef… | ragelink | 9 | # Run from inside the container or via: |
| 45192ef… | ragelink | 10 | # docker compose exec backend bash scripts/sync_to_fossil.sh "message" |
| 45192ef… | ragelink | 11 | |
| 45192ef… | ragelink | 12 | set -euo pipefail |
| 45192ef… | ragelink | 13 | |
| 45192ef… | ragelink | 14 | REPO="/data/repos/fossilrepo.fossil" |
| 45192ef… | ragelink | 15 | WORKDIR="/tmp/fossil-checkout-$$" |
| 45192ef… | ragelink | 16 | MESSAGE="${1:-Sync from working tree}" |
| 45192ef… | ragelink | 17 | |
| 45192ef… | ragelink | 18 | export USER="${USER:-ragelink}" |
| 45192ef… | ragelink | 19 | |
| 45192ef… | ragelink | 20 | if [ ! -f "$REPO" ]; then |
| 45192ef… | ragelink | 21 | echo "Error: $REPO not found" >&2 |
| 45192ef… | ragelink | 22 | exit 1 |
| 45192ef… | ragelink | 23 | fi |
| 45192ef… | ragelink | 24 | |
| 45192ef… | ragelink | 25 | echo "=== Committing to Fossil ===" |
| 45192ef… | ragelink | 26 | |
| 45192ef… | ragelink | 27 | # Create temp checkout |
| 45192ef… | ragelink | 28 | rm -rf "$WORKDIR" |
| 45192ef… | ragelink | 29 | mkdir -p "$WORKDIR" |
| 45192ef… | ragelink | 30 | cd "$WORKDIR" |
| 45192ef… | ragelink | 31 | |
| 45192ef… | ragelink | 32 | fossil open "$REPO" --workdir "$WORKDIR" 2>/dev/null |
| 45192ef… | ragelink | 33 | fossil update trunk 2>/dev/null || true |
| 45192ef… | ragelink | 34 | |
| 45192ef… | ragelink | 35 | # Sync code from /app — use tar to copy with exclusions (rsync not available) |
| 45192ef… | ragelink | 36 | cd /app |
| 45192ef… | ragelink | 37 | tar cf - \ |
| 45192ef… | ragelink | 38 | --exclude='.git' \ |
| 45192ef… | ragelink | 39 | --exclude='__pycache__' \ |
| 45192ef… | ragelink | 40 | --exclude='*.pyc' \ |
| 45192ef… | ragelink | 41 | --exclude='.ruff_cache' \ |
| 45192ef… | ragelink | 42 | --exclude='node_modules' \ |
| 45192ef… | ragelink | 43 | --exclude='assets' \ |
| 45192ef… | ragelink | 44 | --exclude='.env' \ |
| 45192ef… | ragelink | 45 | --exclude='repos' \ |
| 45192ef… | ragelink | 46 | --exclude='.fslckout' \ |
| 45192ef… | ragelink | 47 | --exclude='_FOSSIL_' \ |
| 45192ef… | ragelink | 48 | --exclude='*.fossil' \ |
| 45192ef… | ragelink | 49 | --exclude='.claude' \ |
| 45192ef… | ragelink | 50 | . | (cd "$WORKDIR" && tar xf -) |
| 45192ef… | ragelink | 51 | cd "$WORKDIR" |
| 45192ef… | ragelink | 52 | |
| 45192ef… | ragelink | 53 | # Register new/deleted files |
| 45192ef… | ragelink | 54 | fossil addremove 2>/dev/null || true |
| 45192ef… | ragelink | 55 | |
| 45192ef… | ragelink | 56 | # Commit if there are changes |
| 45192ef… | ragelink | 57 | CHANGES=$(fossil changes 2>/dev/null | wc -l | tr -d ' ') |
| 45192ef… | ragelink | 58 | if [ "$CHANGES" -gt 0 ]; then |
| 45192ef… | ragelink | 59 | fossil commit -m "$MESSAGE" --no-warnings 2>&1 | tail -3 |
| 45192ef… | ragelink | 60 | echo "Committed $CHANGES changed files." |
| 45192ef… | ragelink | 61 | else |
| 45192ef… | ragelink | 62 | echo "No changes to commit." |
| 45192ef… | ragelink | 63 | fi |
| 45192ef… | ragelink | 64 | |
| 45192ef… | ragelink | 65 | # Cleanup |
| 45192ef… | ragelink | 66 | fossil close --force 2>/dev/null || true |
| 45192ef… | ragelink | 67 | cd / |
| 45192ef… | ragelink | 68 | rm -rf "$WORKDIR" |
| 45192ef… | ragelink | 69 | |
| 45192ef… | ragelink | 70 | echo "=== Status ===" |
| 45192ef… | ragelink | 71 | echo "Checkins: $(fossil sql -R "$REPO" "SELECT count(*) FROM event WHERE type='ci';" | tr -d "' ")" |
| 45192ef… | ragelink | 72 | echo "Wiki: $(fossil wiki list -R "$REPO" | wc -l) pages" |
| 45192ef… | ragelink | 73 | echo "Tickets: $(fossil sql -R "$REPO" "SELECT count(*) FROM ticket;" | tr -d "' ")" |