format

package
v0.1.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// A default type rewrite map
	DefaultTypeRewrite = map[string]string{
		"feature": "feat",
		"bug":     "fix",
		"task":    "feat",
		"story":   "feat",
	}
)

Functions

func AllCommitType

func AllCommitType() []string

func ColorizeCommitType

func ColorizeCommitType(s string, ct CommitType) string

func CommitMessage

func CommitMessage(o *CommitMessageOption) string

Format commit message according to https://www.conventionalcommits.org/en/v1.0.0/

Types

type Bump

type Bump int
const (
	BUMP_NONE Bump = iota
	BUMP_PATCH
	BUMP_MINOR
	BUMP_MAJOR
)

func NextBump

func NextBump(cmsg string, curr Bump) Bump

Get the next bump that this commit message would generate

type CommitMessageOption

type CommitMessageOption struct {
	// Commit type (optional)
	Ctype CommitType
	// Commit scope (optional)
	Scope string
	// Commit subject (required)
	Description string
	// Commit body (optional)
	Body string
	// Commit footers (optional)
	Footers []string
	// Breaking change flag (optional)
	BreakingChanges bool
}

func ParseCommitMsg

func ParseCommitMsg(msg string) *CommitMessageOption

func (*CommitMessageOption) Check

func (cmo *CommitMessageOption) Check() error

Check CommitMessageOption compliance

func (*CommitMessageOption) Overwrite

func (cmo *CommitMessageOption) Overwrite(other *CommitMessageOption) error

Overwrite values with another CommitMessageOption.

type CommitType

type CommitType int
const (
	NilCommit CommitType = iota
	BuildCommit
	CiCommit
	ChoreCommit
	DocCommit
	FeatureCommit
	FixCommit
	PerfCommit
	RefactorCommit
	StyleCommit
	TestCommit
)

func FindCommitType

func FindCommitType(str string) CommitType

Extract type from string

func (CommitType) String

func (b CommitType) String() string

type TugBranch

type TugBranch struct {
	// Branch type (e.g. 'feat', 'fix', 'user', etc...)
	Type string
	// Branch prefix (issue id, user name, etc...)
	Prefix string
	// Branch description
	Description string
}

TugBranch represents a turbogit branch

func ParseBranch

func ParseBranch(s string) (TugBranch, error)

ParseBranch parses a given string into a TugBranch or return an error on bad format.

func (TugBranch) String

func (tb TugBranch) String() string

String builds a git-sanitized branch name.

func (TugBranch) WithType

func (tb TugBranch) WithType(t string, rewrite map[string]string) TugBranch

WithType returns a TugBranch with the given type 't' or it's correlation in the rewrite map if it exists.

Jump to

Keyboard shortcuts

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