Skip to content

Add primary-branch option to preserve primary branch spine - #182

Merged
lusingander merged 2 commits into
lusingander:masterfrom
essteec:feat/primary-branch-option
Oct 3, 2026
Merged

lusingander merged 2 commits into
lusingander:masterfrom
essteec:feat/primary-branch-option

Conversation

@essteec

@essteec essteec commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Closes #181

Summary

Adds the -b, --primary-branch <BRANCH> CLI option and core.option.primary_branch configuration setting.

When specified, Serie preserves the first-parent spine of the specified branch along column 0, keeping the trunk visually straight even when feature branches contain newer commits.
When omitted, Serie preserves its existing behavior exactly.

Behavior

  • Lane assignment: The primary branch spine is identified upfront and pinned to column 0 during lane assignment, placing feature branch commits in subsequent columns (column >= 1).
  • Fallback & Notifications: If the specified branch cannot be resolved, or if its tip is excluded from loaded commits due to --max-count, Serie falls back to the standard layout and displays a warning via Serie's native status-line notification (StatusLine::NotificationWarn). This avoids writing to stderr while Ratatui's alternate screen buffer is active.
  • Branch resolution: Resolves the specified branch name against repository local branches (Ref::Branch).

Tests & Docs

  • Graph regression test: Added primary_branch_001 to src/tests/graph.rs with image snapshots covering both chrono and topo orderings under tests/graph/.
  • Unit tests:
    • primary_branch_merge_back: Verifies column stability when feature branches merge back into the primary trunk.
    • primary_branch_fallback_unresolved_or_none: Verifies fallback to default layout and status warning when the branch name cannot be resolved.
    • primary_branch_max_count: Verifies fallback when tip is truncated, and visible spine pinning when older commits are truncated.
  • Documentation: Updated README.md CLI help block, docs/src/getting-started/command-line-options.md, docs/src/configurations/config-file-format.md, and config.schema.json.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 22:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@lusingander lusingander left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! It's mostly ready, but I left some comments for minor details. Could you please check them?

Comment thread src/graph/calc.rs Outdated
Comment thread src/graph/calc.rs Outdated
@essteec

essteec commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

I've made find_primary_branch_tip private and switched to exact case-sensitive matching. Thank you so much for reviewing.

@lusingander
lusingander merged commit 60d7c27 into lusingander:master Oct 3, 2026
8 checks passed
@lusingander

Copy link
Copy Markdown
Owner

Thank you!

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.

Preserve primary branch spine in graph layout

3 participants