Expand description
Gitmoji mapping (issue #85).
This repo standardises commits as <emoji> <type>(#<issue>): <subject>
(Gitmoji + Conventional Commits β see CONTRIBUTING.md). The mapping
branch_type β emoji shortcode is universal across the project, so
we bake a default table into the binary and let .gwm.toml override
individual entries via a [gitmoji] block:
[gitmoji]
feat = ":rocket:" # team uses π for new features instead of β¨Three surfaces consume this module:
gwm commit-prefixβ prints:sparkles: feat(#41):for the current or named branch (with--unicodeto emit β¨ instead).gwm types --gitmojiβ extends the branch-type list with the unicode + shortcode columns.gwm hooks install commit-msgβ installs a.git/hooks/commit-msgthat shells out togwm commit-prefix --unicodeand auto-prepends the prefix when missing.
The shortcode β unicode table is intentionally kept small (the ten
built-in branch types + :question: as the unknown-type fallback)
to avoid pulling in a heavy gh-emoji-style dependency for a
handful of entries.
StructsΒ§
- Gitmoji
Map - Resolved
branch_type β shortcodetable. TheBTreeMapchoice is load-bearing: it gives deterministic iteration order (alphabetical by branch type), whichgwm types --gitmojirelies on so a CI diff against the previous run is byte-stable.
ConstantsΒ§
- DEFAULT_
GITMOJI - Built-in
branch_type β shortcodetable. Lifted to a&[(&str, &str)]const so the static table stays compile-time and zero-alloc at the storage level; the runtime view materialises on demand viadefault_map. The list mirrors the ten built-in branch types declared innaming::BRANCH_TYPES.
FunctionsΒ§
- default_
map - Materialise the built-in table as a
GitmojiMap. The runtime cost is one allocation per built-in entry β measured at ~1Β΅s total in release builds, dominated by theBTreeMapinsertions, so we donβt cache. - load
- Load
.gwm.tomlβs[gitmoji]block from the given repo root and merge it on top of the built-in defaults. Returns the built-in defaults verbatim when the file is missing or the block is absent. - resolve_
prefix - Render the canonical commit prefix for a branch:
<emoji> <type>(#<issue>):. Useunicode = trueto substitute the shortcode for its real emoji character (e.g.:sparkles:β β¨). - shortcode_
to_ unicode - Map a
:shortcode:to its unicode character. Covers the ten built-in defaults plus a curated set of the most commonly-used Gitmoji shortcodes (the ones a team[gitmoji]override is statistically likely to swap to β:rocket:,:fire:,:lock:,:art:,:lipstick:, β¦). Anything outside the table round-trips verbatim: rendering an arbitrary user string under--unicodewould require the full 3000-entry Gitmoji set (a heavy dep) and shortcodes remain valid commit-message decoration anyway. The:question:fallback covers the unknown-branch-type path insideresolve_prefix.