Documentation ¶
Overview ¶
Package commit provides commit-related policies.
Index ¶
- Constants
- Variables
- type Body
- type BodyChecks
- type Commit
- func (c *Commit) Compliance(options *policy.Options) (*policy.Report, error)
- func (c Commit) ValidateBody() policy.Check
- func (c Commit) ValidateConventionalCommit() policy.Check
- func (c Commit) ValidateDCO() policy.Check
- func (c Commit) ValidateGPGIdentity(g *git.Git) policy.Check
- func (c Commit) ValidateGPGSign(g *git.Git) policy.Check
- func (c Commit) ValidateHeaderCase() policy.Check
- func (c Commit) ValidateHeaderLastCharacter() policy.Check
- func (c Commit) ValidateHeaderLength() policy.Check
- func (c Commit) ValidateImperative() policy.Check
- func (c Commit) ValidateJiraCheck() policy.Check
- func (c Commit) ValidateNumberOfCommits(g *git.Git, ref string) policy.Check
- func (c Commit) ValidateSpelling() policy.Check
- type Conventional
- type ConventionalCommitCheck
- type DCOCheck
- type GPG
- type GPGCheck
- type GPGIdentityCheck
- type HeaderCaseCheck
- type HeaderChecks
- type HeaderLastCharacterCheck
- type HeaderLengthCheck
- type ImperativeCheck
- type JiraCheck
- type JiraChecks
- type NumberOfCommits
- type SpellCheck
- type SpellingCheck
Constants ¶
const ( // TypeFeat is a commit of the type fix patches a bug in your codebase // (this correlates with PATCH in semantic versioning). TypeFeat = "feat" // TypeFix is a commit of the type feat introduces a new feature to the // codebase (this correlates with MINOR in semantic versioning). TypeFix = "fix" )
Variables ¶
var DCORegex = regexp.MustCompile(`^Signed-off-by: ([^<]+) <([^<>@]+@[^<>]+)>$`)
DCORegex is the regular expression used for Developer Certificate of Origin.
var FirstWordRegex = regexp.MustCompile(`^\s*([a-zA-Z0-9]+)`)
FirstWordRegex is theregular expression used to find the first word in a commit.
var HeaderRegex = regexp.MustCompile(`^(\w*)(\(([^)]+)\))?(!)?:\s{1}(.*)($|\n{2})`)
HeaderRegex is the regular expression used for Conventional Commits 1.0.0.
var MaxNumberOfCommitCharacters = 89
MaxNumberOfCommitCharacters is the default maximium number of characters allowed in a commit header.
var RequiredBodyThreshold = 10
RequiredBodyThreshold is the default minimum number of line changes required to trigger the body check.
Functions ¶
This section is empty.
Types ¶
type Body ¶
type Body struct {
// contains filtered or unexported fields
}
Body enforces a maximum number of charcters on the commit header.
type BodyChecks ¶
type BodyChecks struct { // Required enforces that the current commit has a body. Required bool `mapstructure:"required"` }
BodyChecks is the configuration for checks on the body of a commit.
type Commit ¶
type Commit struct { // SpellCheck enforces correct spelling. SpellCheck *SpellCheck `mapstructure:"spellcheck"` // Conventional is the user specified settings for conventional commits. Conventional *Conventional `mapstructure:"conventional"` // Header is the user specified settings for the header of each commit. Header *HeaderChecks `mapstructure:"header"` // Header is the user specified settings for the body of each commit. Body *BodyChecks `mapstructure:"body"` // DCO enables the Developer Certificate of Origin check. DCO bool `mapstructure:"dco"` // GPG is the user specified settings for the GPG signature check. GPG *GPG `mapstructure:"gpg"` // GPGSignatureGitHubOrganization enforces that GPG signature should come from // one of the members of the GitHub org. GPGSignatureGitHubOrganization string `mapstructure:"gpgSignatureGitHubOrg"` // MaximumOfOneCommit enforces that the current commit is only one commit // ahead of a specified ref. MaximumOfOneCommit bool `mapstructure:"maximumOfOneCommit"` // contains filtered or unexported fields }
Commit implements the policy.Policy interface and enforces commit messages to conform the Conventional Commit standard.
func (*Commit) Compliance ¶
Compliance implements the policy.Policy.Compliance function.
func (Commit) ValidateBody ¶
ValidateBody checks the header length.
func (Commit) ValidateConventionalCommit ¶
ValidateConventionalCommit returns the commit type.
func (Commit) ValidateDCO ¶
ValidateDCO checks the commit message for a Developer Certificate of Origin.
func (Commit) ValidateGPGIdentity ¶
ValidateGPGIdentity checks the commit GPG signature for a known identity.
func (Commit) ValidateGPGSign ¶
ValidateGPGSign checks the commit message for a GPG signature.
func (Commit) ValidateHeaderCase ¶
ValidateHeaderCase checks the header length.
func (Commit) ValidateHeaderLastCharacter ¶
ValidateHeaderLastCharacter checks the last character of the header.
func (Commit) ValidateHeaderLength ¶
ValidateHeaderLength checks the header length.
func (Commit) ValidateImperative ¶
ValidateImperative checks the commit message for a GPG signature.
func (Commit) ValidateJiraCheck ¶
ValidateJiraCheck validates if a Jira issue is mentioned in the header.
func (Commit) ValidateNumberOfCommits ¶
ValidateNumberOfCommits checks the header length.
func (Commit) ValidateSpelling ¶
ValidateSpelling checks the spelling.
type Conventional ¶
type Conventional struct { Types []string `mapstructure:"types"` Scopes []string `mapstructure:"scopes"` DescriptionLength int `mapstructure:"descriptionLength"` }
Conventional implements the policy.Policy interface and enforces commit messages to conform the Conventional Commit standard.
type ConventionalCommitCheck ¶
type ConventionalCommitCheck struct {
// contains filtered or unexported fields
}
ConventionalCommitCheck ensures that the commit message is a valid conventional commit.
func (ConventionalCommitCheck) Errors ¶
func (c ConventionalCommitCheck) Errors() []error
Errors returns any violations of the check.
func (ConventionalCommitCheck) Message ¶
func (c ConventionalCommitCheck) Message() string
Message returns to check message.
func (ConventionalCommitCheck) Name ¶
func (c ConventionalCommitCheck) Name() string
Name returns the name of the check.
type DCOCheck ¶
type DCOCheck struct {
// contains filtered or unexported fields
}
DCOCheck ensures that the commit message contains a Developer Certificate of Origin.
type GPG ¶
type GPG struct { // Required enforces that the current commit has a signature. Required bool `mapstructure:"required"` // Identity configures identity of the signature. Identity *struct { // GitHubOrganization enforces that commit should be signed with the key // of one of the organization public members. GitHubOrganization string `mapstructure:"gitHubOrganization"` } `mapstructure:"identity"` }
GPG is the configuration for checks GPG signature on the commit.
type GPGCheck ¶
type GPGCheck struct {
// contains filtered or unexported fields
}
GPGCheck ensures that the commit is cryptographically signed using GPG.
type GPGIdentityCheck ¶
type GPGIdentityCheck struct {
// contains filtered or unexported fields
}
GPGIdentityCheck ensures that the commit is cryptographically signed using known identity.
func (GPGIdentityCheck) Errors ¶
func (g GPGIdentityCheck) Errors() []error
Errors returns any violations of the check.
func (GPGIdentityCheck) Message ¶
func (g GPGIdentityCheck) Message() string
Message returns to check message.
func (GPGIdentityCheck) Name ¶
func (g GPGIdentityCheck) Name() string
Name returns the name of the check.
type HeaderCaseCheck ¶
type HeaderCaseCheck struct {
// contains filtered or unexported fields
}
HeaderCaseCheck enforces the case of the first word in the header.
func (HeaderCaseCheck) Errors ¶
func (h HeaderCaseCheck) Errors() []error
Errors returns any violations of the check.
func (HeaderCaseCheck) Message ¶
func (h HeaderCaseCheck) Message() string
Message returns to check message.
func (HeaderCaseCheck) Name ¶
func (h HeaderCaseCheck) Name() string
Name returns the name of the check.
type HeaderChecks ¶
type HeaderChecks struct { // Length is the maximum length of the commit subject. Length int `mapstructure:"length"` // Imperative enforces the use of imperative verbs as the first word of a // commit message. Imperative bool `mapstructure:"imperative"` // HeaderCase is the case that the first word of the header must have ("upper" or "lower"). Case string `mapstructure:"case"` // HeaderInvalidLastCharacters is a string containing all invalid last characters for the header. InvalidLastCharacters string `mapstructure:"invalidLastCharacters"` // Jira checks if the header containers a Jira project key. Jira *JiraChecks `mapstructure:"jira"` }
HeaderChecks is the configuration for checks on the header of a commit.
type HeaderLastCharacterCheck ¶
type HeaderLastCharacterCheck struct {
// contains filtered or unexported fields
}
HeaderLastCharacterCheck enforces that the last character of the header isn't in some set.
func (HeaderLastCharacterCheck) Errors ¶
func (h HeaderLastCharacterCheck) Errors() []error
Errors returns any violations of the check.
func (HeaderLastCharacterCheck) Message ¶
func (h HeaderLastCharacterCheck) Message() string
Message returns to check message.
func (HeaderLastCharacterCheck) Name ¶
func (h HeaderLastCharacterCheck) Name() string
Name returns the name of the check.
type HeaderLengthCheck ¶
type HeaderLengthCheck struct {
// contains filtered or unexported fields
}
HeaderLengthCheck enforces a maximum number of charcters on the commit header.
func (HeaderLengthCheck) Errors ¶
func (h HeaderLengthCheck) Errors() []error
Errors returns any violations of the check.
func (HeaderLengthCheck) Message ¶
func (h HeaderLengthCheck) Message() string
Message returns to check message.
func (HeaderLengthCheck) Name ¶
func (h HeaderLengthCheck) Name() string
Name returns the name of the check.
type ImperativeCheck ¶
type ImperativeCheck struct {
// contains filtered or unexported fields
}
ImperativeCheck enforces that the first word of a commit message header is and imperative verb.
func (ImperativeCheck) Errors ¶
func (i ImperativeCheck) Errors() []error
Errors returns any violations of the check.
func (ImperativeCheck) Message ¶
func (i ImperativeCheck) Message() string
Message returns to check message.
func (ImperativeCheck) Name ¶
func (i ImperativeCheck) Name() string
Name returns the name of the check.
type JiraCheck ¶
type JiraCheck struct {
// contains filtered or unexported fields
}
JiraCheck enforces that a Jira issue is mentioned in the header.
type JiraChecks ¶
type JiraChecks struct {
Keys []string `mapstructure:"keys"`
}
JiraChecks is the configuration for checks for Jira issues.
type NumberOfCommits ¶
type NumberOfCommits struct {
// contains filtered or unexported fields
}
NumberOfCommits enforces a maximum number of charcters on the commit header.
func (NumberOfCommits) Errors ¶
func (h NumberOfCommits) Errors() []error
Errors returns any violations of the check.
func (NumberOfCommits) Message ¶
func (h NumberOfCommits) Message() string
Message returns to check message.
func (NumberOfCommits) Name ¶
func (h NumberOfCommits) Name() string
Name returns the name of the check.
type SpellCheck ¶
type SpellCheck struct {
Locale string `mapstructure:"locale"`
}
SpellCheck represents to spell check policy.
type SpellingCheck ¶
type SpellingCheck struct {
// contains filtered or unexported fields
}
SpellingCheck enforces correct spelling.
func (SpellingCheck) Errors ¶
func (h SpellingCheck) Errors() []error
Errors returns any violations of the check.
func (SpellingCheck) Message ¶
func (h SpellingCheck) Message() string
Message returns to check message.
func (SpellingCheck) Name ¶
func (h SpellingCheck) Name() string
Name returns the name of the check.