Documentation
¶
Overview ¶
Package validators provides functionality for managing and compiling custom validators for commit messages.
Index ¶
- Variables
- func GetGitccCacheDir() (string, error)
- func GetValidatorCacheDir() (string, error)
- func PruneValidators() (deletedDirs []string, err error)
- type DB
- func (db *DB) AvailableNames() []string
- func (db *DB) CompileCustom(path string, name string, hash string) (validatorPath string, err error)
- func (db *DB) GetBuiltin(name string) (gitcc.ValidatorConstructor, error)
- func (db *DB) GetCustom(path string) string
- func (db *DB) GetCustomByName(name string) string
- func (db *DB) GetOrCompileCustom(path string, name string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidNameAndPath = errors.New("invalid name and path")
ErrInvalidNameAndPath is returned when both name and path are invalid.
var ErrValidatorNotFound = errors.New("validator not found")
ErrValidatorNotFound is returned when a requested validator is not found in the database.
Functions ¶
func GetGitccCacheDir ¶
GetGitccCacheDir returns the path to the cache directory for gitcc, creating it if it does not exist.
func GetValidatorCacheDir ¶
GetValidatorCacheDir returns the path to the cache directory for validators, creating it if it does not exist.
func PruneValidators ¶
PruneValidators removes all validator versions from the cache directory except for the current version and returns the list of deleted directories.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a database of validators, including both built-in and custom validators. The database it no ment to be in a long running session, compiled validators are not added.
func NewDB ¶
NewDB initializes a new DB instance by loading built-in validators and refreshing custom validators from the cache directory.
func (*DB) AvailableNames ¶
AvailableNames returns a list of all available validator names, including both built-in and custom validators.
func (*DB) CompileCustom ¶
func (db *DB) CompileCustom(path string, name string, hash string) (validatorPath string, err error)
CompileCustom compiles a custom validator from the specified source file and stores it in the database. If a validator with the same name or hash already exists, it will be replaced. If the hash is not provided, it will be computed from the source file.
func (*DB) GetBuiltin ¶
func (db *DB) GetBuiltin(name string) (gitcc.ValidatorConstructor, error)
GetBuiltin retrieves a built-in validator by its name. If the validator is not found, ErrValidatorNotFound is returned.
func (*DB) GetCustom ¶
GetCustom retrieves a custom validator by the file path of its source code. Only absolute paths should be passed.
func (*DB) GetCustomByName ¶
GetCustomByName retrieves a custom validator by its name.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package regex provides a validator that checks if the commit message summary and description match specified regular expressions.
|
Package regex provides a validator that checks if the commit message summary and description match specified regular expressions. |
|
Package simpletag implements a simple tag validator.
|
Package simpletag implements a simple tag validator. |