โฏ๏ธ Ast::Merge::Git
if ci_badges.map(&:color).detect { it != "green"} โ๏ธ let me know on Discord or RubyForum, as I may have missed the notification.
if ci_badges.map(&:color).all? { it == "green"} ๐๏ธ send money so I can do more of this. FLOSS maintenance is now my full-time job.
๐ฃ How will this project approach the September 2025 hostile takeover of RubyGems? ๐๏ธ
I've summarized my thoughts in this blog post.
๐ป Synopsis

ast-merge-git adapts StructuredMerge contracts to Git merge-driver workflows. It translates Git driver inputs into family-aware merge requests and reports structured diagnostics that can be surfaced by repository tooling.
Key Features
- Git-oriented request and response shaping for three-way merge driver integrations.
- Provider selection from explicit family/provider, dialect, backend, and profile selectors.
- JSON-compatible reports that can be logged, inspected, or replayed by higher-level tooling.
- Fallback-friendly behavior for unsupported families or unsafe parser results.
๐ก Info you can shake a stick at
| Tokens to Remember | |
|---|---|
| Works with MRI Ruby 4 | |
| Support & Community | |
| Source | |
| Documentation | |
| Compliance | |
| Style | |
| Maintainer ๐๏ธ | |
... ๐ |
Compatibility
Compatible with MRI Ruby 4.0.0+, JRuby, and TruffleRuby.
CI workflows and Appraisals are generated for MRI Ruby 4.0.0+.
This test floor is configured by ruby.test_minimum in .kettle-jem.yml and
may be higher than the gem's runtime compatibility floor when legacy Rubies are
not practical for the current toolchain.
The amazing test matrix is powered by the kettle-dev stack.
How kettle-dev manages complexity in tests
| Gem | Source | Role | Total downloads |
|---|---|---|---|
| appraisal2 | GitHub | multi-dependency Appraisal matrix generation | |
| appraisal2-rubocop | GitHub | RuboCop Appraisal generator integration | |
| kettle-dev | GitHub | development, release, and CI workflow tooling | |
| kettle-jem | GitHub | Appraisals & CI workflow templates | |
| kettle-soup-cover | GitHub | SimpleCov coverage policy and reporting | |
| kettle-test | GitHub | standard test runner and coverage harness | |
| rubocop-lts | GitHub | Ruby-version-aware linting | |
| turbo_tests2 | GitHub | parallel test execution |
โจ Installation
Install the gem and add to the application's Gemfile by executing:
bundle add ast-merge-git
If bundler is not being used to manage dependencies, install the gem by executing:
gem install ast-merge-git
โ๏ธ Configuration
Configure ast-merge-git through the repository's Git attributes and StructuredMerge provider settings. The gem expects callers to provide the ancestor, current, and incoming file contents that Git passes to a custom merge driver.
Keep family-specific parser configuration in the corresponding merge gem. For example, Markdown backend choices belong to markdown-merge or its provider gems, while Ruby source backend choices belong to ruby-merge or prism-merge.
The executable does not infer or require family implementations. Configure
AST_MERGE_REQUIRE with comma-separated provider require paths and select a
provider with AST_MERGE_FAMILY or AST_MERGE_PROVIDER. Optional selectors are
AST_MERGE_DIALECT, AST_MERGE_BACKEND, and AST_MERGE_PROFILE.
[merge "structured-json"]
name = StructuredMerge JSON-family driver
driver = AST_MERGE_REQUIRE=json/merge AST_MERGE_FAMILY=json AST_MERGE_DIALECT=json ast-merge-git %O %A %B %P %L
๐ง Basic Usage
require "ast/merge/git"
require "json/merge"
result = Ast::Merge::Git.merge3(
family: "json",
dialect: "json",
base_source: File.binread("%O"),
ours_source: File.binread("%A"),
theirs_source: File.binread("%B"),
)
if result.fetch(:ok)
File.binwrite("%A", result.fetch(:merged_source))
else
File.binwrite("%A", result.fetch(:conflicted_source)) if result[:conflicted_source]
abort result.fetch(:diagnostics).inspect
end
For direct Git-driver execution, ast-merge-git writes clean provider output to
%A and exits 0. Unresolved conflicts exit 1; unsupported capabilities,
invalid provider output, configuration failures, and file errors exit 2.
AST_MERGE_CONFLICT_POLICY=leave_ours prevents conflicted output from replacing
%A; the default write policy writes provider conflict output when available.
๐ Security
See SECURITY.md.
๐ค Contributing
If you need some ideas of where to help, you could work on adding more code coverage, check issues or PRs, or use the gem and think about how it could be better.
We so if you make changes, remember to update it.
See CONTRIBUTING.md for more detailed instructions.
๐ Versioning
This library follows for its public API where practical.
For most applications, prefer the Pessimistic Version Constraint with two digits of precision.
For example:
spec.add_dependency("ast-merge-git", "~> 7.0")
๐ Is "Platform Support" part of the public API? More details inside.
Dropping support for a platform can be a breaking change for affected users. If a release changes supported platforms, it should be called out clearly in the changelog and versioned with that impact in mind.
To get a better understanding of how SemVer is intended to work over a project's lifetime, read this article from the creator of SemVer:
See CHANGELOG.md for a list of releases.
๐ License
The gem is available under the following licenses: AGPL-3.0-only, PolyForm-Small-Business-1.0.0. See LICENSE.md for details.
If none of the available licenses suit your use case, please contact us to discuss a custom commercial license.
