Skip to main content

Module merge_driver

Module merge_driver 

Source
Expand description

Git merge driver for spec files.

This module implements a custom merge driver for .chant/specs/*.md files that intelligently resolves frontmatter conflicts while preserving body content.

§Problem

When merging spec branches back to main, frontmatter conflicts occur because:

  • Main has status: completed (from finalize)
  • Feature branch has status: in_progress
  • Main may have completed_at and model fields
  • Feature branch may not have these fields yet

§Solution

This merge driver:

  1. Parses frontmatter from base, ours, and theirs versions
  2. Intelligently merges frontmatter fields
  3. Uses standard 3-way merge for body content
  4. Produces a clean merge result or marks conflicts

§Git Configuration

To use this merge driver, add to .gitattributes:

.chant/specs/*.md merge=chant-spec

Then configure git:

git config merge.chant-spec.name "Chant spec merge driver"
git config merge.chant-spec.driver "chant merge-driver %O %A %B"

§Doc Audit

  • audited: 2026-01-27
  • docs: guides/recovery.md
  • ignore: false

Structs§

MergeDriverSetupResult
Result of setting up the merge driver
ParsedSpec
Result of parsing a spec file into frontmatter and body

Functions§

assemble_spec
Assemble a spec file from frontmatter and body
get_setup_instructions
Generate git configuration instructions for the merge driver
merge_body
Merge body content using git’s 3-way merge
merge_frontmatter
Merge frontmatter from base, ours, and theirs
parse_spec_file
Parse a spec file into frontmatter and body components
run_merge_driver
Run the merge driver
serialize_frontmatter
Serialize frontmatter back to YAML string
setup_merge_driver
Set up the merge driver for the current repository