Skip to content

fix(workspace): clone the run's tree at repo.baseBranch, not the origin's HEAD #76

Description

@FreshlyBrewedCode

What happened

A run's working tree is checked out at the origin's HEAD, not at repo.baseBranch.
allocateWorkspace (src/lib/workspace.ts) runs git clone <mirror> <dir>, which checks out the
mirror's HEAD, the remote's default branch. baseBranch is used only by write-back, as the PR's
base.

Found during #62's live legs (#72, #67). A local bare origin created with git init --bare
may have HEAD → master, and its runs did not start from main until HEAD was pointed at
main.

Real-world effect: for a project whose PRs target a branch other than the remote's default (for
example baseBranch: "develop" on a repository whose default is main), the agent works on
main, and write-back opens a PR against develop with main's history in the diff.

Fix

Pass baseBranch into WorkspaceAllocationInput and clone with git clone --branch <baseBranch> <mirror> <dir>, or check it out after the clone. If the branch is missing, the allocation
should fail with a message that names it. Add a workspace.test.ts case with a bare origin whose
HEAD differs from baseBranch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions