diff options
| author | Jesse Vincent <jesse@fsck.com> | 2025-10-11 12:02:15 -0700 |
|---|---|---|
| committer | Jesse Vincent <jesse@fsck.com> | 2025-10-11 12:02:15 -0700 |
| commit | 60cb0cd0ca243181e43b8703e585ea7758fac8ee (patch) | |
| tree | a4441970d21aeaca481026e959cc1370fab00b19 | |
| parent | 661e6292c61fefdec0dfc91b139f167b5b1c3686 (diff) | |
Auto-update skills repo with fast-forward merge on session start
| -rwxr-xr-x | lib/initialize-skills.sh | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/initialize-skills.sh b/lib/initialize-skills.sh index cd3ee4d..4d8ee89 100755 --- a/lib/initialize-skills.sh +++ b/lib/initialize-skills.sh @@ -11,12 +11,20 @@ if [ -d "$SKILLS_DIR/.git" ]; then # Fetch upstream git fetch upstream 2>/dev/null || git fetch origin 2>/dev/null || true - # Check if behind upstream + # Check if we can fast-forward LOCAL=$(git rev-parse @ 2>/dev/null || echo "") REMOTE=$(git rev-parse @{u} 2>/dev/null || echo "") + BASE=$(git merge-base @ @{u} 2>/dev/null || echo "") if [ -n "$LOCAL" ] && [ -n "$REMOTE" ] && [ "$LOCAL" != "$REMOTE" ]; then - echo "⚠️ New skills available from upstream. Ask me to use the updating-skills skill." + # Check if we can fast-forward (local is ancestor of remote) + if [ "$LOCAL" = "$BASE" ]; then + # Fast-forward merge is possible + git merge --ff-only @{u} 2>/dev/null && echo "✓ Skills updated to latest version" || true + else + # Can't fast-forward (diverged or local is ahead) + echo "⚠️ New skills available from upstream. Ask me to use the pulling-updates-from-skills-repository skill." + fi fi exit 0 |
