Documentation
¶
Index ¶
- func LintIssue(issue *types.Issue) error
- func ParseIssueType(content string) (types.IssueType, error)
- func ParsePriority(content string) int
- func ValidateIDFormat(id string) (string, error)
- func ValidateIDPrefixAllowed(id, dbPrefix, allowedPrefixes string, force bool) error
- func ValidatePriority(priorityStr string) (int, error)
- func ValidateTemplate(issueType types.IssueType, description string) error
- type IssueValidator
- func Chain(validators ...IssueValidator) IssueValidator
- func EpicHasOpenChildren(force bool, openChildCount int) IssueValidator
- func Exists() IssueValidator
- func HasStatus(allowed ...types.Status) IssueValidator
- func HasType(allowed ...types.IssueType) IssueValidator
- func NotClosed() IssueValidator
- func NotHooked(force bool) IssueValidator
- func NotPinned(force bool) IssueValidator
- func NotTemplate() IssueValidator
- type MissingSection
- type TemplateError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LintIssue ¶
LintIssue checks an existing issue for missing template sections. Unlike ValidateTemplate, this operates on a full Issue struct. It checks both Description and AcceptanceCriteria fields. A non-empty AcceptanceCriteria field satisfies the "Acceptance Criteria" (or "Success Criteria" for epics) requirement without needing a heading. (GH#2468) Returns nil if the issue passes validation or has no requirements.
func ParseIssueType ¶
ParseIssueType extracts and validates an issue type from content. Returns the validated type or error if invalid. Supports type aliases like "enhancement" -> "feature".
func ParsePriority ¶
ParsePriority extracts and validates a priority value from content. Supports both numeric (0-4) and P-prefix format (P0-P4). Returns the parsed priority (0-4) or -1 if invalid.
func ValidateIDFormat ¶
ValidateIDFormat validates that an ID has the correct format. Supports: prefix-number (bd-42), prefix-hash (bd-a3f8e9), or hierarchical (bd-a3f8e9.1) Also supports hyphenated prefixes like "bead-me-up-3e9" or "web-app-abc123". Returns the prefix part or an error if invalid.
func ValidateIDPrefixAllowed ¶
ValidateIDPrefixAllowed checks that an issue ID's prefix is allowed. Unlike validatePrefixWithAllowed which takes an extracted prefix, this function takes the full ID and checks if it starts with any allowed prefix. This correctly handles multi-hyphen prefixes like "hq-cv-" where the suffix might look like an English word (e.g., "hq-cv-test"). (GH#1135)
It matches if: - force is true - dbPrefix is empty - id starts with dbPrefix + "-" - id starts with any prefix in allowedPrefixes + "-" Returns an error if none of these conditions are met.
func ValidatePriority ¶
ValidatePriority parses and validates a priority string. Returns the parsed priority (0-4) or an error if invalid. Supports both numeric (0-4) and P-prefix format (P0-P4).
func ValidateTemplate ¶
ValidateTemplate checks if the description contains all required sections for the given issue type. Returns nil if validation passes or if the issue type has no required sections.
Section matching is case-insensitive and looks for the heading text anywhere in the description (doesn't require exact markdown format).
Types ¶
type IssueValidator ¶
IssueValidator validates an issue and returns an error if validation fails. Validators can be composed using Chain() for complex validation logic.
func Chain ¶
func Chain(validators ...IssueValidator) IssueValidator
Chain composes multiple validators into a single validator. Validators are executed in order and the first error stops the chain.
func EpicHasOpenChildren ¶
func EpicHasOpenChildren(force bool, openChildCount int) IssueValidator
EpicHasOpenChildren validates that an epic does not have open children. If the issue is an epic with open children, returns an error unless force is true. Non-epic issues pass through without validation.
func HasStatus ¶
func HasStatus(allowed ...types.Status) IssueValidator
HasStatus validates that an issue has one of the allowed statuses.
func HasType ¶
func HasType(allowed ...types.IssueType) IssueValidator
HasType validates that an issue has one of the allowed types.
func NotClosed ¶
func NotClosed() IssueValidator
NotClosed validates that an issue is not already closed.
func NotHooked ¶
func NotHooked(force bool) IssueValidator
NotHooked validates that an issue is not in hooked status.
func NotPinned ¶
func NotPinned(force bool) IssueValidator
NotPinned validates that an issue is not pinned. Returns an error if the issue is pinned, unless force is true.
func NotTemplate ¶
func NotTemplate() IssueValidator
NotTemplate validates that an issue is not a template. Templates are read-only and cannot be modified.
type MissingSection ¶
type MissingSection struct {
Heading string // The expected heading, e.g., "## Steps to Reproduce"
Hint string // Guidance for what to include
}
MissingSection describes a section that should be present but isn't.
type TemplateError ¶
type TemplateError struct {
IssueType types.IssueType
Missing []MissingSection
}
TemplateError is returned when template validation fails. It contains all missing sections for a single error report.
func (*TemplateError) Error ¶
func (e *TemplateError) Error() string