commitinfo

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldService            = "Service"
	FieldEnvironment        = "Environment"
	FieldArtifactID         = "Artifact-ID"
	FieldArtifactReleasedBy = "Artifact-released-by"
	FieldArtifactCreatedBy  = "Artifact-created-by"
)
View Source
const (
	FieldReleaseIntent           = "Release-intent"
	FieldRollbackOfArtifactId    = "Rollback-of-artifact-id"
	FieldReleaseOfBranch         = "Release-of-branch"
	FieldPromotedFromEnvironment = "Promoted-from-environment"
)

Variables

View Source
var (
	ErrNoMatch = fmt.Errorf("no match")
)

Functions

func LocateRelease

func LocateRelease(validator func(CommitInfo) bool) conditionFunc

func PolicyUpdateApplyCommitMessage

func PolicyUpdateApplyCommitMessage(env, service, policy string) string

PolicyUpdateApplyCommitMessage returns an apply policy commit message.

func PolicyUpdateDeleteCommitMessage

func PolicyUpdateDeleteCommitMessage(service string) string

PolicyUpdateDeleteCommitMessage returns a delete policy commit message.

func ReleaseCommitMessage

func ReleaseCommitMessage(env, service, artifactID string, intent intent.Intent, artifactAuthor, releaseAuthor PersonInfo) string

ReleaseCommitMessage returns an artifact release commit message.

Types

type CommitInfo

type CommitInfo struct {
	ArtifactID        string
	ArtifactCreatedBy PersonInfo
	ReleasedBy        PersonInfo
	Service           string
	Environment       string
	Intent            intent.Intent
}

func ParseCommitInfo

func ParseCommitInfo(commitMessage string) (CommitInfo, error)

ParseCommitInfo takes a full git commit message in the ConventionalCommit format and tries to extract release information from it It will extract it using conventional commit fields first, but if the correct fields isn't there it will fallback to parsing message for backward compatability reasons. The following backward-compatibility actions are done in the parsing (if not found in the fields!):

  • If `artifact` is written in title, the commit info is considered a "no match"
  • If `rollback` is written in title, the Intent is considered to be rollback intent, as well as the PreviousArtifactID is attempted to be extracted
  • Environment and Service name is extracted from the `[<env>/<service>]`-brackets in the title
  • User email in title is interpreted as releaser

func (CommitInfo) String

func (i CommitInfo) String() string

type ConventionalCommitInfo

type ConventionalCommitInfo struct {
	Message     string
	Description string
	Fields      []Field
}

func ParseConventionalCommit

func ParseConventionalCommit(commitMessage string) (ConventionalCommitInfo, error)

func (ConventionalCommitInfo) Field

func (i ConventionalCommitInfo) Field(name string) string

func (ConventionalCommitInfo) HasField added in v0.9.1

func (i ConventionalCommitInfo) HasField(name string) bool

func (*ConventionalCommitInfo) SetField

func (i *ConventionalCommitInfo) SetField(name string, value string)

func (ConventionalCommitInfo) String

func (i ConventionalCommitInfo) String() string

type Field

type Field struct {
	Name  string
	Value string
}

func NewField

func NewField(name, value string) Field

type PersonInfo

type PersonInfo struct {
	Name  string
	Email string
}

func NewPersonInfo

func NewPersonInfo(name, email string) PersonInfo

func ParsePerson

func ParsePerson(personInfo string) (PersonInfo, error)

func (PersonInfo) String

func (i PersonInfo) String() string

Jump to

Keyboard shortcuts

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