Skip to content

Commit 6bcec18

Browse files
authored
Merge branch 'main' into update-notifier
2 parents 166a8d4 + 6d3f9eb commit 6bcec18

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.claude/hooks/session-start.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,39 @@ fi
5959
log "syncing uv environment (locked dev group)"
6060
uv sync
6161

62+
# 4. Keep the session branch current. Resumed web containers hold a clone frozen
63+
# at creation time, so two things can go stale: the branch's own remote tip
64+
# (pushes from another session/machine) and origin/main (which the diff-scoped
65+
# gates — diff-cover, mutation — compare against). Fast-forward to the remote
66+
# tip if it advanced, then merge origin/main if behind (the same semantics as
67+
# GitHub's "Update branch" button). Never force anything: a dirty tree skips
68+
# the update and a conflicting merge is aborted with a note, leaving the
69+
# resolution to the session.
70+
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "HEAD")
71+
if [ "$branch" != "HEAD" ] && [ "$branch" != "main" ]; then
72+
if [ -n "$(git status --porcelain)" ]; then
73+
log "working tree is dirty; skipping branch auto-update"
74+
elif git fetch origin main "$branch" 2>/dev/null || git fetch origin main 2>/dev/null; then
75+
if git rev-parse --verify --quiet "origin/$branch" >/dev/null; then
76+
if git merge-base --is-ancestor "HEAD" "origin/$branch" && [ "$(git rev-parse HEAD)" != "$(git rev-parse "origin/$branch")" ]; then
77+
git merge --ff-only "origin/$branch"
78+
log "fast-forwarded $branch to its remote tip"
79+
fi
80+
fi
81+
behind=$(git rev-list --count "HEAD..origin/main" 2>/dev/null || echo 0)
82+
if [ "$behind" -gt 0 ]; then
83+
if git merge --no-edit origin/main; then
84+
log "merged origin/main into $branch (was $behind commit(s) behind)"
85+
else
86+
git merge --abort 2>/dev/null || true
87+
log "WARNING: origin/main conflicts with $branch; left unmerged — resolve with 'git merge origin/main'"
88+
fi
89+
else
90+
log "$branch is up to date with origin/main"
91+
fi
92+
else
93+
log "could not fetch origin; skipping branch auto-update"
94+
fi
95+
fi
96+
6297
log "provisioning complete"

0 commit comments

Comments
 (0)