trailerparser

package
v16.9.10 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(input []byte) []*gitalypb.CommitTrailer

Parse parses Git trailers into a list of CommitTrailer objects.

The expected input is a single line containing trailers in the following format:

KEY:VALUE\0KEY:VALUE

Where \0 is a NULL byte. The input should not end in a NULL byte.

Trailers must be separated with a null byte, as their values can include any other separator character. NULL bytes however are not allowed in commit messages, and thus can't occur in trailers.

The key-value separator must be a colon, as this is the separator the Git CLI uses when obtaining the trailers of a commit message.

Trailer keys and values are limited to a certain number of bytes. If these limits are reached, parsing stops and all trailers parsed until that point are returned. This ensures we don't continue to consume a potentially very large input.

The limits this parser imposes on the sizes/amounts are loosely based on trailers found in GitLab's own repository. Here are just a few examples:

Change-Id: I009c716ce2475b9efa3fd07aee9215fca7a1c150
Changelog: https://github.com/nahi/httpclient/blob/b51d7a8bb78f71726b08fbda5abfb900d627569f/CHANGELOG.md#changes-in-282
Co-Authored-By: Alex Kalderimis <akalderimis@gitlab.com>
fixes: https://gitlab.com/gitlab-org/gitlab-ce/issues/44458
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
See: https://gitlab.com/gitlab-org/gitlab-ee/blob/ff9ad690650c23665439499d23f3ed22103b55bb/spec/spec_helper.rb#L50

Types

This section is empty.

Jump to

Keyboard shortcuts

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