changes

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package changes contains tools for working with change logs written in a particular format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractSection

func ExtractSection(fn string, vstring string) (io.Reader, error)

ExtractSection will return a reader that will output the bullets that are written below the changelog heading for the given version. The first argument is the file name of the changelog to open and the second line is a semver string to search for. Returns an error if there is a problem reading the file or if the version heading is not found.

Types

type CheckMode

type CheckMode int

CheckMode identifies the kind of linting to perform on a changelog.

const (
	// CheckStandard merely checks that the syntax of the changelog file appears
	// to be sane.
	CheckStandard CheckMode = 0 + iota

	// CheckPreRelease checks the syntax and then checks that the first section
	// is a WIP section.
	CheckPreRelease

	// CheckRelease checks the syntax and then checks that the first section is
	// not a WIP section.
	CheckRelease
)

type Error

type Error struct {
	Failures
}

Error is an error made up of Failures and is returned by the Linter.Check method when one or more problems are detected in the changelog.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message as a string.

type Failure

type Failure struct {
	Line    int
	Message string
}

Failure describes a line that has some defect and the description of the defect.

type Failures

type Failures []Failure

Failures is a list of changelog errors.

func (Failures) String

func (fs Failures) String() string

String outputs the Failures as a bulleted list.

type Linter

type Linter struct {
	// contains filtered or unexported fields
}

Linter is the object with methods for performing changelog linting. The expected format for changelogs being linted by this method looks like this:

WIP  TBD

 * This is a change line for the work in progress.
 * This is a long line that will end up wrapped in the file because it is
   long and long lines are tedious if you have to scroll horizontally.

v1.0  2023-03-04

 * This is the change for the latest release.

A changelog is made up of one or more sections. Each section starts with a heading of the form "<vstring> <date>" with exactly two spaces between the vstring and date. The first section may be "WIP TBD". (During a pre-release check, the first section must be a WIP section and during a release check, the first section must not be a WIP section.) This heading must be followed by a blank line. Then there are one or more bullet lines, each of which must start with " * " at the very start of the line. A bullet line may be continued on one or more following lines by ensuring that at least 3 spaces start each of those lines. Finally, prior to starting a new section head there must be another blank. Other than that, anything goes.

func NewLinter

func NewLinter(r io.Reader, mode CheckMode) *Linter

NewLinter constructs a Linter for checking a changelog file.

func (*Linter) Check

func (l *Linter) Check() error

Check executes the changelog linter against the reader. It scans each line of the changelog and checks it for problems. If there are no errors, this method returns nil. If one or more problems are detected, they will be returned as an Error.

Jump to

Keyboard shortcuts

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