validators

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package validators provides functionality for managing and compiling custom validators for commit messages.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidNameAndPath = errors.New("invalid name and path")

ErrInvalidNameAndPath is returned when both name and path are invalid.

View Source
var ErrValidatorNotFound = errors.New("validator not found")

ErrValidatorNotFound is returned when a requested validator is not found in the database.

Functions

func GetGitccCacheDir

func GetGitccCacheDir() (string, error)

GetGitccCacheDir returns the path to the cache directory for gitcc, creating it if it does not exist.

func GetValidatorCacheDir

func GetValidatorCacheDir() (string, error)

GetValidatorCacheDir returns the path to the cache directory for validators, creating it if it does not exist.

func PruneValidators

func PruneValidators() (deletedDirs []string, err error)

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

func NewDB() (*DB, error)

NewDB initializes a new DB instance by loading built-in validators and refreshing custom validators from the cache directory.

func (*DB) AvailableNames

func (db *DB) AvailableNames() []string

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

func (db *DB) GetCustom(path string) string

GetCustom retrieves a custom validator by the file path of its source code. Only absolute paths should be passed.

func (*DB) GetCustomByName

func (db *DB) GetCustomByName(name string) string

GetCustomByName retrieves a custom validator by its name.

func (*DB) GetOrCompileCustom

func (db *DB) GetOrCompileCustom(path string, name string) (string, error)

GetOrCompileCustom retrieves a custom validator by the file path or compiles it if it does not exist or is outdated.

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.

Jump to

Keyboard shortcuts

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