Documentation ¶
Overview ¶
Package footer implements parsing logic for git footer and its predecessor (legacy `<KEY>=<arbitrary value>` style).
The git footer parsing functionality is a slimmed downed version of git_footers.py in depot_tools. See: https://chromium.googlesource.com/chromium/tools/depot_tools/+/master/git_footers.py
Index ¶
- func NormalizeKey(footerKey string) string
- func ParseLegacyMetadata(message string) strpair.Map
- func ParseLine(line string) (string, string)
- func ParseLines(lines []string) strpair.Map
- func ParseMessage(message string) strpair.Map
- func SplitLines(message string) (nonFooterLines, footerLines []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeKey ¶
NormalizeKey normalizes a git footer key string. It removes leading and trailing spaces and converts each segment (separated by `-`) to title case.
func ParseLegacyMetadata ¶
ParseLegacyMetadata extracts legacy style `<KEY>=<value>` metadata from the given message. Unlike git footer, this works across *all* lines instead of the last paragraph only. Returns a multimap as a key may map to multiple values. The metadata defined in a latter line takes precedence and shows up at the front of the value slice.
func ParseLine ¶
ParseLine tries to extract a git footer from a commit message line. Returns a normalized key and value (with surrounding space trimmed) if the line represents a valid footer. Returns empty strings otherwise.
func ParseLines ¶
ParseLines extracts all footers from the given lines. Returns a multimap as a footer key may map to multiple values. The footer in a latter line takes precedence and shows up at the front of the value slice. Ideally, this function should be called with the `footerLines` part of the return values of `SplitLines`.
func ParseMessage ¶
ParseMessage extracts all footers from the footer lines of given message. A shorthand for `SplitLines` + `ParseLines`.
func SplitLines ¶
SplitLines splits a commit message to non-footer and footer lines.
Footer lines are all lines in the last paragraph of the message if it:
- contains at least one valid footer (it may contains lines that are not valid footers in the middle).
- is not the only paragraph in the message.
One exception is that if the last paragraph starts with text then followed by valid footers, footer lines will only contain all lines after the first valid footer, all the lines above will be included in non-footer lines and a new line will be appended to separate them from footer lines.
The leading and trailing whitespaces (including new lines) of the given message will be trimmed before splitting.
Types ¶
This section is empty.