trailer

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package trailer reads git trailers from a commit message.

Extracted from package policy when a second consumer appeared: the version decision reads Release-As:, and release notes read Release-Note:. Two copies of a parser this fiddly would have drifted, and the fiddliness is the point — see Block on what "a trailer" actually means.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Block

func Block(body string) []string

Block returns the lines of a commit message's git trailer block, or nil when it has none.

Why this is not "any line with a colon in it"

An earlier implementation scanned every line of the body. A fenced example in a commit message —

Example:

```yaml
Release-As: 9.0.0
```

— was therefore read as an instruction, and a documentation snippet could cut a permanent major-version tag.

Git's rule is narrower and is the one applied here: the trailer block is the LAST paragraph of the message, and it qualifies only if every one of its non-continuation lines is a "Key: value" pair. Anything after it — prose, a closing fence, a stray sentence — means there is no trailer block at all.

func Paragraphs

func Paragraphs(body string) [][]string

Paragraphs breaks a message into blank-line-separated groups of non-empty lines.

func Values

func Values(body, key string) []string

Values returns EVERY value for a key in the trailer block, matched case-insensitively.

All of them, not the last: a body carrying two Release-As lines is a caller stating two things, and silently keeping one hides both the conflict and any malformed value that happened to come first.

Continuation lines are FOLDED into the value above them, as git does, so

Release-As:
  1.0.0

is one trailer whose value is "1.0.0". Verified against `git interpret-trailers --parse` rather than inferred.

Types

This section is empty.

Jump to

Keyboard shortcuts

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