Skip to content

fix: refresh remote PR worktree bases#787

Merged
tomdps merged 4 commits into
the-open-engine:devfrom
shixi-li:fix/remote-pr-base
Jul 24, 2026
Merged

fix: refresh remote PR worktree bases#787
tomdps merged 4 commits into
the-open-engine:devfrom
shixi-li:fix/remote-pr-base

Conversation

@shixi-li

@shixi-li shixi-li commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Explicit PR bases were passed to Git as local short refs, so a stale local branch could change the worktree start commit even when the remote branch was current.

Related Issues

Fixes #711

Changes Made

  • fetch explicit PR bases into a unique temporary ref without updating shared remote-tracking refs or FETCH_HEAD
  • resolve the exact temporary ref to a commit before creating the worktree, then clean it up without masking the original result
  • require fresh remote data only for explicit PR bases while preserving cached offline behavior for repository worktree settings
  • cover foreground and detached-derived starts, short-ref collisions, shared-ref lock contention, fetch failure, and temporary-ref cleanup

Testing

  • node tests/run-tests.js tests/integration/worktree-isolation.test.js --timeout 30000 --jobs 1 (28 passing)
  • relevant orchestrator, detached-startup, and PR-base tests (94 passing, 1 pending)
  • npm run check
  • Prettier on all changed files
  • npm run test:all
  • npm audit --omit=dev --audit-level=high
  • git diff --check origin/dev...HEAD

Checklist

  • Tests pass (npm test)
  • Documentation updated (not needed for this behavior-only fix)
  • Follows commit guidelines

@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown

Greptile Summary

Refreshes explicit PR worktree bases without mutating shared Git refs.

  • Fetches the requested remote branch into a unique temporary ref and resolves its commit before worktree creation.
  • Cleans up temporary refs on success and failure while preserving cached behavior for repository-configured bases.
  • Passes explicit PR bases through the fresh-fetch path and adds coverage for contention, stale refs, failures, and cleanup.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failures remain in the fix associated with the previous review thread.

Important Files Changed

Filename Overview
src/isolation-manager.js Fetches explicit PR bases through isolated temporary refs, creates worktrees from resolved commits, and reliably attempts temporary-ref cleanup.
src/orchestrator.js Routes explicit PR bases to refreshed origin refs and records the resolved worktree base commit.
tests/integration/worktree-isolation.test.js Adds integration coverage for fresh PR bases, shared-ref contention, fetch failures, immutable base selection, and temporary-ref cleanup.
tests/orchestrator.test.js Updates orchestrator expectations for origin-qualified PR bases and mandatory fresh fetching.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Explicit PR base] --> B[Fetch remote branch]
  B --> C[Unique temporary ref]
  C --> D[Resolve immutable commit SHA]
  D --> E[Create worktree from SHA]
  E --> F[Delete temporary ref]
Loading

Reviews (3): Last reviewed commit: "chore: sync latest dev fix" | Re-trigger Greptile

Comment thread src/isolation-manager.js Outdated
@tomdps
tomdps added this pull request to the merge queue Jul 24, 2026
Merged via the queue into the-open-engine:dev with commit d73d6eb Jul 24, 2026
6 checks passed
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