Skip to content

Add configurable base branch per repo#76

Merged
0101 merged 8 commits into
mainfrom
basebranch
May 21, 2026
Merged

Add configurable base branch per repo#76
0101 merged 8 commits into
mainfrom
basebranch

Conversation

@0101
Copy link
Copy Markdown
Owner

@0101 0101 commented May 21, 2026

Problem

Every repo is hardcoded to use main as the base branch for ahead/behind counts, diff stats, fetch targets, fast-forward, merge/rebase in the sync pipeline, and branch sort priority. Repos that use dev or develop as their primary branch show incorrect metrics.

Changes

Add per-repo baseBranch config to .treemon.json (defaults to "main" when omitted):

{ "baseBranch": "dev" }

Config layer (TreemonConfig.fs):

  • readBaseBranch reads the setting with branch-name validation (allows / for hierarchical branches, rejects leading dashes)

Git operations (GitWorktree.fs):

  • mainRef, fetchUpstream, tryFastForwardMain, branchSortKey all parameterized with baseBranch instead of hardcoded "main"

State propagation (RefreshScheduler.fs, SyncEngine.fs, WorktreeApi.fs):

  • BaseBranch field on PerRepoState, read from config during worktree list refresh
  • Threaded through all callers: refresh cycle, sync pipeline, branch sorting, worktree creation

UI badge (App.fs, Navigation.fs, Types.fs):

  • When baseBranch differs from "main", a badge appears on the repo header row (reuses deploy-branch CSS class)

Spec updates (worktree-monitor.md, new configurable-base-branch.md)

Tests

  • 21 new unit tests for readBaseBranch config reading + validation, mainRef parameterization, branchSortKey with custom base branch
  • All 627 unit tests pass

0101 added 8 commits May 21, 2026 13:00
Added readBaseBranch function to TreemonConfig.fs with validation.
14 unit tests in UpstreamRemoteTests.fs ReadBaseBranchTests class.
Parameterized mainRef, fetchUpstream, tryFastForwardMain, branchSortKey
in GitWorktree.fs with baseBranch parameter. Updated callers in
RefreshScheduler.fs, SyncEngine.fs, WorktreeApi.fs to pass 'main' default.
Added mainRef and branchSortKey tests.
Added BaseBranch field to PerRepoState + UpdateBaseBranch StateMsg in RefreshScheduler.fs.
Read config via TreemonConfig.readBaseBranch during RefreshWorktreeList.
Passed repo.BaseBranch to all mainRef/fetchUpstream/branchSortKey/executeSyncPipeline callers.
…s and reject leading dashes

Add validBranchNamePattern that requires alphanumeric first char and allows slashes.
Use it in readBaseBranch instead of validRemoteNamePattern.
Add 4 tests: slash branches accepted, dash-prefixed branches rejected.
…baseBranch

Fix stale reference to hardcoded {remote}/main, add Base Branch Resolution section.
Add BaseBranch to RepoWorktrees and RepoModel types, populate from
PerRepoState, and render a deploy-branch badge on the repo section
header when the configured base branch differs from main.
All useful content is already in worktree-monitor.md Base Branch Resolution subsection.
@0101 0101 merged commit e7cb381 into main May 21, 2026
1 check 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.

1 participant