forked from Aider-AI/aider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsync.sh
executable file
·45 lines (31 loc) · 916 Bytes
/
rsync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
set -e
if [ $# -ne 1 ]; then
echo "Usage: $0 user@host"
exit 1
fi
DEST="$1"
REPO_ROOT="$(git rev-parse --show-toplevel)"
# Create a temporary file for rsync exclude patterns
EXCLUDE_FILE=$(mktemp)
# Convert .gitignore patterns to rsync exclude patterns
git -C "$REPO_ROOT" ls-files --exclude-standard --others --ignored --directory > "$EXCLUDE_FILE"
# Create remote directory if needed
ssh "$DEST" "mkdir -p ~/aider"
sync_repo() {
# Sync the repository
rsync -avz --delete \
--exclude-from="$EXCLUDE_FILE" \
"$REPO_ROOT/" \
"$DEST:~/aider/" || sleep 0.1
rsync -av .env .gitignore .aider.model.settings.yml "$DEST:~/aider/." || sleep 0.1
echo Done syncing, waiting.
}
sync_repo
while true; do
fswatch -o $REPO_ROOT | while read ; do
sync_repo
done
done
# Clean up
rm "$EXCLUDE_FILE"