Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommitCorrection ¶ added in v0.3.0
func SuggestCorrection ¶ added in v0.3.0
func SuggestCorrection(message string, config *KeywordsConfig) (*CommitCorrection, error)
SuggestCorrection analyzes an invalid commit message and suggests corrections
type KeywordType ¶ added in v0.3.0
type KeywordsConfig ¶ added in v0.3.0
type KeywordsConfig struct { CommitTypes []KeywordType `yaml:"commit_types"` CommitScopes []KeywordType `yaml:"commit_scopes"` }
func LoadKeywords ¶ added in v0.3.0
func LoadKeywords() (*KeywordsConfig, error)
type Linter ¶
type Linter struct {
// contains filtered or unexported fields
}
func (*Linter) LintCommitMessage ¶
LintCommitMessage lints a single commit message from a string
func (*Linter) LintCommitMessageFile ¶
LintCommitMessageFile lints a commit message from a file path
func (*Linter) LintCommits ¶
LintCommits lints the commit messages in the given range and returns an error if any commit fails the linting rules.
The function accepts a Git commit range (e.g., "HEAD~5..HEAD") and validates each commit message against the configured linting rules. It performs the following checks:
- Commit message format validation
- Commit type verification
- Scope requirement check (if enabled)
- Message length validation
For any commits that fail validation, it generates detailed error messages including:
- The commit hash
- The specific validation failure
- Step-by-step instructions for fixing the commit
Example usage:
git-commit-linter --config=config.yaml --check="HEAD~5..HEAD"
Returns nil if all commits pass validation, or error details if any commits fail.
type ValidationError ¶ added in v0.3.0
type ValidationError struct {
Message string
}
func (*ValidationError) Error ¶ added in v0.3.0
func (e *ValidationError) Error() string