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