#!/bin/bash
# Auto-sync Obsidian vault to git remote
# Runs daily via Windows Task Scheduler

VAULT_DIR="/c/Users/yaoji/git/Knowledge"
cd "$VAULT_DIR" || exit 1

# Check if there are any changes
if git diff --quiet && git diff --cached --quiet && [ -z "$(git ls-files --others --exclude-standard)" ]; then
    echo "$(date): No changes to sync"
    exit 0
fi

# Stage all changes
git add -A

# Commit with timestamp
git commit -m "vault: auto-sync $(date '+%Y-%m-%d %H:%M')"

# Push to remote
git push origin main

echo "$(date): Sync complete"
