message

package
v0.0.0-...-832881f Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBeamsRules

func NewBeamsRules(appIO io.IO, conf *configuration.Configuration, repo git.Repo) hooks.Action

func NewCacheOnFail

func NewCacheOnFail(appIO io.IO, conf *configuration.Configuration, repo git.Repo) hooks.Action

func NewContainsRegex

func NewContainsRegex(appIO io.IO, conf *configuration.Configuration, repo git.Repo) hooks.Action

func NewInjectIssueKeyFromBranch

func NewInjectIssueKeyFromBranch(appIO io.IO, conf *configuration.Configuration, repo git.Repo) hooks.Action

func NewPrepare

func NewPrepare(appIO io.IO, conf *configuration.Configuration, repo git.Repo) hooks.Action

func NewPrepareFromFile

func NewPrepareFromFile(appIO io.IO, conf *configuration.Configuration, repo git.Repo) hooks.Action

Types

type BeamsRules

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

BeamsRules blocks commits if the commit message is not following these rules.

  • Commit message is not empty
  • Subject has to start with upper case letter
  • No period at end of subject
  • Subject not longer than 50 characters
  • Body line not longer than 72 characters
  • Subject is written in imperative mood
  • There is an empty line between subject and body

Example configuration:

{
  "run": "CaptainHook::Message.MustFollowBeamsRules",
  "options: {
    "subject-length": 50,
    "body-line-length": 72,
    "check-subject-beginning-only": false
  }
}

func (*BeamsRules) IsApplicableFor

func (a *BeamsRules) IsApplicableFor(hook string) bool

func (*BeamsRules) Run

func (a *BeamsRules) Run(action *configuration.Action) error

type CacheOnFail

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

CacheOnFail writes the commit message to a cache file if the message validation fails. This way you can use the cache file to prepare your commit message.

Example configuration:

{
  "run": "CaptainHook::Message.CacheOnFail",
  "options: {
    "file": ".git/CH_COMMIT_MSG_CACHE"
  }
}

func (*CacheOnFail) IsApplicableFor

func (a *CacheOnFail) IsApplicableFor(hook string) bool

func (*CacheOnFail) Run

func (a *CacheOnFail) Run(action *configuration.Action) error

func (*CacheOnFail) Subscribe

func (a *CacheOnFail) Subscribe(dispatcher *events.Dispatcher, action *configuration.Action) error

type CacheOnFailEventHandler

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

func NewCacheOnFailEventHandler

func NewCacheOnFailEventHandler(bundle *hooks.HookBundle, path string) *CacheOnFailEventHandler

func (*CacheOnFailEventHandler) Handle

func (h *CacheOnFailEventHandler) Handle(event *events.HookFailed) error

type CapitalizeSubject

type CapitalizeSubject struct{}

func NewCapitalizeSubject

func NewCapitalizeSubject() *CapitalizeSubject

func (*CapitalizeSubject) IsFollowedBy

func (r *CapitalizeSubject) IsFollowedBy(msg *types.CommitMessage) (bool, string)

type ContainsRegex

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

ContainsRegex blocks commits if the commit message is not matching the given regex.

Example configuration:

{
  "run": "CaptainHook::Message.ContainsRegex",
  "options: {
    "regex": "mustContainThis"
  }
}

func (*ContainsRegex) IsApplicableFor

func (a *ContainsRegex) IsApplicableFor(hook string) bool

func (*ContainsRegex) Run

func (a *ContainsRegex) Run(action *configuration.Action) error

type InjectIssueKeyFromBranch

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

InjectIssueKeyFromBranch loads a suggested commit message from a given file. It is the counterpart of CacheOnFail. If your commit failed because of an invalid message you can use the action to preload the failed message, so you can edit it without having to completely write it from scratch again.

Example configuration:

{
  "run": "CaptainHook::Message.InjectIssueKeyFromBranch",
  "options": {
    "regex": "([A-Z]+\\-[0-9]+)",
    "into": "body",
    "mode": "append",
    "prefix": "issue: ",
    "force": true
  }
}

func (*InjectIssueKeyFromBranch) IsApplicableFor

func (a *InjectIssueKeyFromBranch) IsApplicableFor(hook string) bool

func (*InjectIssueKeyFromBranch) Run

type LimitBodyLineLength

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

func NewLimitBodyLineLength

func NewLimitBodyLineLength(length int) *LimitBodyLineLength

func (*LimitBodyLineLength) IsFollowedBy

func (r *LimitBodyLineLength) IsFollowedBy(msg *types.CommitMessage) (bool, string)

type LimitSubjectLineLength

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

func NewLimitSubjectLineLength

func NewLimitSubjectLineLength(length int) *LimitSubjectLineLength

func (*LimitSubjectLineLength) IsFollowedBy

func (r *LimitSubjectLineLength) IsFollowedBy(msg *types.CommitMessage) (bool, string)

type MsgNotEmpty

type MsgNotEmpty struct{}

func NewMsgNotEmpty

func NewMsgNotEmpty() *MsgNotEmpty

func (*MsgNotEmpty) IsFollowedBy

func (r *MsgNotEmpty) IsFollowedBy(msg *types.CommitMessage) (bool, string)

type NoPeriodOnSubjectEnd

type NoPeriodOnSubjectEnd struct{}

func NewNoPeriodOnSubjectEnd

func NewNoPeriodOnSubjectEnd() *NoPeriodOnSubjectEnd

func (*NoPeriodOnSubjectEnd) IsFollowedBy

func (r *NoPeriodOnSubjectEnd) IsFollowedBy(msg *types.CommitMessage) (bool, string)

type Prepare

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

Prepare is used to prefill your commit messages with some defaults. It only works if you commit message is empty so far.

Example configuration:

{
  "run": "CaptainHook::Message.Prepare",
  "options": {
    "subject": "My prepared subject",
    "body": "My prepared body"
  }
}

func (*Prepare) IsApplicableFor

func (a *Prepare) IsApplicableFor(hook string) bool

func (*Prepare) Run

func (a *Prepare) Run(action *configuration.Action) error

type PrepareFromFile

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

PrepareFromFile loads a suggested commit message from a given file. It is the counterpart of CacheOnFail. If your commit failed because of an invalid message you can use the action to preload the failed message. This way you can edit it without having to completely write it from scratch again. If the current commit message is not empty it will add it the cached message as comment at the bottom.

Example configuration:

{
  "run": "CaptainHook::Message.PrepareFromFile",
  "options": {
    "file": ".git/CH_COMMIT_MSG"
  }
}

func (*PrepareFromFile) IsApplicableFor

func (a *PrepareFromFile) IsApplicableFor(hook string) bool

func (*PrepareFromFile) Run

func (a *PrepareFromFile) Run(action *configuration.Action) error

func (*PrepareFromFile) Subscribe

func (a *PrepareFromFile) Subscribe(dispatcher *events.Dispatcher, action *configuration.Action) error

type PrepareFromFileEventHandler

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

func NewPrepareFromFileEventHandler

func NewPrepareFromFileEventHandler(bundle *hooks.HookBundle, path string) *PrepareFromFileEventHandler

func (*PrepareFromFileEventHandler) Handle

type Rule

type Rule interface {
	IsFollowedBy(msg *types.CommitMessage) (bool, string)
}

Rule is used to define rules that commit messages should follow. If a commit message does not follow a rule the commit gets aborted.

type Rulebook

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

Rulebook is a container around Rule(s) that makes sure to check all configured rules.

func NewRulebook

func NewRulebook() *Rulebook

func (*Rulebook) AddRule

func (r *Rulebook) AddRule(rules ...Rule)

func (*Rulebook) IsFollowedBy

func (r *Rulebook) IsFollowedBy(message *types.CommitMessage) (bool, []string)

type SeparateSubjectFromBodyWithBlankLine

type SeparateSubjectFromBodyWithBlankLine struct{}

func NewSeparateSubjectFromBodyWithBlankLine

func NewSeparateSubjectFromBodyWithBlankLine() *SeparateSubjectFromBodyWithBlankLine

func (*SeparateSubjectFromBodyWithBlankLine) IsFollowedBy

type UseImperativeMood

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

func NewUseImperativeMood

func NewUseImperativeMood(beginningOnly bool) *UseImperativeMood

func (*UseImperativeMood) IsFollowedBy

func (r *UseImperativeMood) IsFollowedBy(msg *types.CommitMessage) (bool, string)

Jump to

Keyboard shortcuts

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