Skip to content

fix(taskctl): detect default branch dynamically instead of hardcoding 'dev' #353

@randomm

Description

@randomm

Problem

taskctl start hardcodes dev as the base branch in two places:

  1. packages/opencode/src/tasks/job-commands.ts:84git checkout -b feature/issue-NNN dev
  2. packages/opencode/src/tasks/pulse-scheduler.ts:155-190git rev-parse --verify dev and git merge-base dev HEAD

This breaks taskctl start in any repo whose mainline is not named dev (e.g. main, master, trunk).

Fix

Detect the default branch dynamically using:

git symbolic-ref refs/remotes/origin/HEAD --short
# → e.g. "origin/main" → strip prefix → "main"

This pattern already exists in packages/opencode/src/worktree/index.ts. Extract it into a shared utility and use it in both executeStart and pulse-scheduler.ts.

Fallback chain if detection fails:

  1. git symbolic-ref refs/remotes/origin/HEAD --short
  2. git remote show origin | grep 'HEAD branch'
  3. 'dev' (last resort)

Quality Gates

  • Tests written (TDD preferred)
  • Coverage meets project threshold
  • Linting passes
  • Local verification complete

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