Help us shape the future of Go! Take the 2026 Go Developer Survey

commit

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package commit contains helpers to derive MR/PR metadata from a commit message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Body

func Body(msg string) string

Body returns everything after the first line, with surrounding whitespace removed. It is empty when the commit message has no body.

func BranchName added in v0.7.0

func BranchName(title string) string

BranchName derives a branch name like "fix-detect" from a commit title. Rules:

  • Input is the commit message title (first line). Whitespace is trimmed.
  • If it matches conventional-commit form type(scope)!: description — word1 = type (lowercase, scope and ! stripped), word2 = first word of description.
  • Otherwise fallback: take the first two usable words of the title.
  • Each word is normalized: lowercased, keep only [a-z0-9] runes. Words that become empty after normalization are skipped.
  • If only one usable word exists, return just that word.
  • If zero usable words, return "" (caller falls back to timestamp).

func MRDescription

func MRDescription(msg string) string

MRDescription mirrors the Bash build_mr_description: when the commit has a body it is returned verbatim, otherwise a short "## Summary" description is generated from the title.

func Title

func Title(msg string) string

Title returns the first line of a commit message.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL