Skip to content

Constants

Constants for commit linting.

FOOTER_DETECTION_MIN_LINES module-attribute

FOOTER_DETECTION_MIN_LINES = 2

FOOTER_MIN_LINE_INDEX module-attribute

FOOTER_MIN_LINE_INDEX = 2

MIN_BODY_LINE_INDEX module-attribute

MIN_BODY_LINE_INDEX = 2

ASCII_MAX_VALUE module-attribute

ASCII_MAX_VALUE = 127

COMMIT_REGEX module-attribute

COMMIT_REGEX = compile(
	"^(?P<type>[a-zA-Z]+)(?:\\((?P<scope>[a-zA-Z0-9\\-_]*(?:/[a-zA-Z0-9\\-_]*)?)\\))?(?P<breaking>!)?: (?P<description>.+?)(?:\\r?\\n\\r?\\n(?P<body_and_footers>.*))?$",
	DOTALL | MULTILINE | IGNORECASE,
)

FOOTER_REGEX module-attribute

FOOTER_REGEX = compile(
	"^(?P<token>(?:BREAKING[ -]CHANGE)|(?:[A-Z][A-Z0-9\\-]+))(?P<separator>: | #)(?P<value_part>.*)",
	MULTILINE | DOTALL,
)
POTENTIAL_FOOTER_TOKEN_REGEX = compile(
	"^([A-Za-z][A-Za-z0-9\\-]+|[Bb][Rr][Ee][Aa][Kk][Ii][Nn][Gg][ -][Cc][Hh][Aa][Nn][Gg][Ee])(: | #)",
	MULTILINE,
)

BREAKING_CHANGE module-attribute

BREAKING_CHANGE = 'BREAKING CHANGE'

BREAKING_CHANGE_HYPHEN module-attribute

BREAKING_CHANGE_HYPHEN = 'BREAKING-CHANGE'
VALID_FOOTER_TOKEN_REGEX = compile(
	"^(?:[A-Z][A-Z0-9\\-]+|BREAKING[ -]CHANGE)$"
)

VALID_TYPE_REGEX module-attribute

VALID_TYPE_REGEX = compile('^[a-zA-Z]+$')

VALID_SCOPE_REGEX module-attribute

VALID_SCOPE_REGEX = compile(
	"^[a-zA-Z0-9\\-_]*(?:/[a-zA-Z0-9\\-_]*)*$"
)

BREAKING_CHANGE_REGEX module-attribute

BREAKING_CHANGE_REGEX = compile(
	"^breaking[ -]change$", IGNORECASE
)

CASE_FORMATS module-attribute

CASE_FORMATS = {
	"lower-case": lambda s: lower() == s,
	"upper-case": lambda s: upper() == s,
	"camel-case": lambda s: s
	and islower()
	and " " not in s
	and "-" not in s
	and "_" not in s,
	"kebab-case": lambda s: lower() == s
	and "-" in s
	and " " not in s
	and "_" not in s,
	"pascal-case": lambda s: s
	and isupper()
	and " " not in s
	and "-" not in s
	and "_" not in s,
	"sentence-case": lambda s: s
	and isupper()
	and lower() == s[1:],
	"snake-case": lambda s: lower() == s
	and "_" in s
	and " " not in s
	and "-" not in s,
	"start-case": lambda s: all(
		isupper() for w in split() if w
	),
}