Skip to content

feat: configuration for default branch#81

Open
antonio-ivanovski wants to merge 2 commits intosatococoa:mainfrom
antonio-ivanovski:feat/config-default-branch
Open

feat: configuration for default branch#81
antonio-ivanovski wants to merge 2 commits intosatococoa:mainfrom
antonio-ivanovski:feat/config-default-branch

Conversation

@antonio-ivanovski
Copy link
Copy Markdown

@antonio-ivanovski antonio-ivanovski commented Jan 28, 2026

Adds optional defaults.default_branch in .wtp.yml for wtp add -b so new worktrees can start from a configured branch when no commit is given; otherwise it still uses the current HEAD.

Summary by CodeRabbit

  • New Features

    • Support for a configurable default_branch in .wtp.yml; creating a worktree without an explicit branch will use the configured default when present.
  • Documentation

    • Quick Start updated with clearer distinctions and explicit example commands for creating worktrees from HEAD vs. from the configured default branch.
  • Tests

    • Added tests covering behavior with and without a configured default branch.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

Adds a default_branch field to configuration, threads config into the wtp add command builder, and falls back to the configured default branch when creating a new worktree with no explicit branch; tests and README updated accordingly.

Changes

Cohort / File(s) Summary
Configuration Schema & Parsing
internal/config/config.go, internal/config/config_test.go
Add DefaultBranch string to Defaults (yaml:"default_branch,omitempty"); tests updated to parse, persist, and round-trip the new field.
Add Command Implementation
cmd/wtp/add.go
Thread cfg *config.Config into buildWorktreeCommand; when no resolved tracking and no explicit commitish provided, use cfg.Defaults.DefaultBranch as fallback for worktree creation. Signature for buildWorktreeCommand changed.
Add Command Tests
cmd/wtp/add_test.go
New test cases exercising configured default branch vs. no-default behavior; tests wire cfg.Defaults.DefaultBranch into command construction.
Documentation
README.md
Quick Start updated with explicit worktree examples and default_branch documented in Defaults section.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI
  participant Config as Config Loader
  participant Builder as Worktree Builder
  participant Git as Git Executor

  User->>CLI: wtp add (no -b)
  CLI->>Config: load .wtp.yml
  Config-->>CLI: cfg (includes DefaultBranch?)
  CLI->>Builder: buildWorktreeCommand(cfg, args)
  alt DefaultBranch present
    Builder->>Git: git worktree add ... <default_branch>
  else No DefaultBranch
    alt tracking resolved
      Builder->>Git: git worktree add ... <resolved tracking>
    else
      Builder->>Git: git worktree add ... (no branch -> HEAD)
    end
  end
  Git-->>User: worktree created
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • satococoa

Poem

🐰 I found a default branch in the hay,
Threaded through commands to show the way,
No "-b" you say? I softly fuss—
The config nudges worktrees thus,
Hoppity, code blooms bright today! 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: configuration for default branch' directly and concisely summarizes the main change: adding configuration support for a default branch setting.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@satococoa satococoa self-requested a review January 31, 2026 19:07
@satococoa
Copy link
Copy Markdown
Owner

@antonio-ivanovski
Thanks for the contribution!

I want to keep wtp simple, so I’m cautious about adding new config options. With that in mind, could you share the motivation / concrete use case for this change?

Since wtp add -b <new-branch> <commit> already allows an explicit base, I want to understand where defaults.default_branch provides meaningful value in real usage.

@antonio-ivanovski
Copy link
Copy Markdown
Author

@satococoa
First, thanks for the great utility, the best ergonomics for working with worktrees so far.

To answer your question. My main use case for using worktrees is providing my coding agents their own worktree. This should almost always be from origin/main. I could live without this feature, but having a default makes it a bit easier.

@satococoa
Copy link
Copy Markdown
Owner

satococoa commented Jan 31, 2026

@antonio-ivanovski

Thanks for the context — that makes sense.

Given the goal of keeping wtp simple, I’d prefer not to add a new config option right now. As a practical workaround, could you have your coding agent use wtp add -b <branch> origin/main explicitly? And if you’re creating worktrees manually, please use origin/main as the base as well.

If this becomes a broader need beyond that workflow, I’m open to revisiting.

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