1
0
Fork
You've already forked tree-sitter-git-commit
0
tree-sitter grammar for git commit messages
  • C 82.6%
  • Tree-sitter Query 8.9%
  • JavaScript 6.8%
  • Just 1.7%
Marian Buschsieweke d574a5948b
feat(queries): style well known trailers as keywords
This makes it easy to spot when typing a trailer by hand whether there is
a typo or not.
Also fixed the indent of some queries.
2026年06月17日 08:25:40 +02:00
bindings chore: tree-sitter init 2026年06月07日 21:10:35 +02:00
queries feat(queries): style well known trailers as keywords 2026年06月17日 08:25:40 +02:00
src chore: tree-sitter generate 2026年06月09日 21:50:00 +02:00
test/corpus fix: improve correctness 2026年06月09日 21:48:28 +02:00
.clang-format feat: add basic grammar to parse commit messages 2026年06月07日 21:10:35 +02:00
.editorconfig feat: add basic grammar to parse commit messages 2026年06月07日 21:10:35 +02:00
.gitattributes feat: add basic grammar to parse commit messages 2026年06月07日 21:10:35 +02:00
.gitignore feat: add basic grammar to parse commit messages 2026年06月07日 21:10:35 +02:00
binding.gyp chore: tree-sitter init 2026年06月07日 21:10:35 +02:00
Cargo.toml chore: tree-sitter init 2026年06月07日 21:10:35 +02:00
CMakeLists.txt chore: tree-sitter init 2026年06月07日 21:10:35 +02:00
go.mod chore: tree-sitter init 2026年06月07日 21:10:35 +02:00
grammar.js fix: improve correctness 2026年06月09日 21:48:28 +02:00
justfile feat: add basic grammar to parse commit messages 2026年06月07日 21:10:35 +02:00
Makefile feat: add basic grammar to parse commit messages 2026年06月07日 21:10:35 +02:00
package.json chore: tree-sitter init 2026年06月07日 21:10:35 +02:00
Package.swift chore: tree-sitter init 2026年06月07日 21:10:35 +02:00
pyproject.toml chore: tree-sitter init 2026年06月07日 21:10:35 +02:00
README.md feat: add basic grammar to parse commit messages 2026年06月07日 21:10:35 +02:00
setup.py feat: add basic grammar to parse commit messages 2026年06月07日 21:10:35 +02:00
tree-sitter.json feat: add basic grammar to parse commit messages 2026年06月07日 21:10:35 +02:00

Tree-Sitter Grammar to Parse Git Commit Messages

This repository contains a tree-sitter grammar to parse the git commit message. It detects the basic structure (subject, message, trailers, comments) as well as special keywords (such as fixup! and squash!) and conventional commit syntax.

See Also

  • tree-sitter-gitcommit by @gbprod is a more feature rich grammar to parse git commit messages
  • [tree-sitter-git-rebase by @the-mikedavis] is a grammar to parse git's interactive rebase file

Motivation

Since there already is tree-sitter-gitcommit, why bother writing a competing grammar?

  1. The parser in tree-sitter-gitcommit is huge
  • Its source is over 3 MiB or 88,000 lines of code and the compiled library is larger than the one of the rust grammar
  • Building for WASM reliably triggers the OOM reaper, even with 64 GiB RAM
  • This grammar is tiny by comparison
  1. Maintainability
  • tree-sitter-gitcommit is parsing against long known phrases instead of the structure
  • each localization needs to be added by hand
  • if git fixes a typo in a message, the grammar needs to change
  • the inability to build WASM makes debugging using the playground impossible
  1. Features
  • Many git forges markdown in commit messages and adding injection queries for that helps me a lot