Skip to content

Auto-update session branch to remote tip and origin/main#78

Merged
alexkroman merged 3 commits into
mainfrom
claude/admiring-gates-044zq5
Jun 11, 2026
Merged

Auto-update session branch to remote tip and origin/main#78
alexkroman merged 3 commits into
mainfrom
claude/admiring-gates-044zq5

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Summary

Add automatic branch synchronization to the session startup hook. When a session resumes, the branch is now kept current with its remote tip and merged with origin/main if behind, ensuring diff-scoped gates (diff-cover, mutation) compare against the latest upstream state.

Changes

  • Branch auto-update logic in session-start.sh:
    • Fetches the current branch's remote tip and origin/main
    • Fast-forwards the branch to its remote tip if it has advanced (no-op if already current)
    • Merges origin/main into the branch if behind, with a commit count logged
    • Skips updates if the working tree is dirty or if fetch fails
    • Aborts conflicting merges and logs a warning, leaving resolution to the user
    • Never force-pushes or rewrites history

Implementation Details

  • Only runs on named branches (skips HEAD detached state and main itself)
  • Uses --ff-only for the branch fast-forward to prevent accidental merges
  • Uses --no-edit for the origin/main merge to avoid interactive prompts
  • Gracefully handles network failures and missing remote branches
  • Provides clear logging at each step for visibility into what happened

https://claude.ai/code/session_014KGbtj3XCDk8SvkteHfsai

claude added 2 commits June 11, 2026 22:41
Resumed web containers hold a clone frozen at creation time, so the
branch's own remote tip and origin/main both go stale. On session start,
fast-forward to the remote tip if it advanced and merge origin/main when
behind (GitHub "Update branch" semantics). A dirty tree skips the
update and a conflicting merge is aborted with a note instead of leaving
the tree half-merged.

https://claude.ai/code/session_014KGbtj3XCDk8SvkteHfsai
@alexkroman alexkroman enabled auto-merge (squash) June 11, 2026 22:42
@alexkroman alexkroman merged commit 6d3f9eb into main Jun 11, 2026
8 checks passed
@alexkroman alexkroman deleted the claude/admiring-gates-044zq5 branch June 11, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants