Documentation
¶
Overview ¶
Package filter provides notification filtering based on configurable rules.
Package filter provides notification filtering based on configurable rules.
Package filter provides notification filtering based on configurable rules.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompiledRule ¶
type CompiledRule struct {
Name string // Human-readable name of the rule
Reasons ValueFilter // Filter for notification reason (assigned, mentioned, etc.)
Repos ValueFilter // Filter for repository name
Types ValueFilter // Filter for notification type (Issue, PullRequest, etc.)
TitleRegex *regexp.Regexp // Optional regex pattern for notification title
}
CompiledRule is a filter rule with pre-compiled regular expressions for efficient matching. All conditions within a rule use AND logic; all must match for the rule to apply.
type Config ¶
type Config struct {
DaysAgo int `yaml:"since_days_ago"` // Number of days to look back for notifications
Filters []Rule `yaml:"filters"` // List of filter rules to apply
}
Config represents the top-level configuration for notification filtering. It specifies the time range for fetching notifications and the filter rules to apply.
func LoadDefault ¶
LoadDefault loads the configuration from the default location (~/.config/gh-quoi/config.yaml). Returns an error if the file cannot be read or parsed.
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher evaluates notifications against a set of compiled filter rules. It determines whether a notification should be displayed based on the configured criteria.
func NewMatcher ¶
NewMatcher creates a new Matcher from the provided configuration. It compiles all regular expressions and returns an error if any regex is invalid.
type Rule ¶
type Rule struct {
Name string `yaml:"name"` // Human-readable name for the rule
Reasons ValueFilter `yaml:"reasons"` // Filter by notification reason
Repos ValueFilter `yaml:"repos"` // Filter by repository name
Types ValueFilter `yaml:"types"` // Filter by notification type
TitleRegex string `yaml:"title_regex"` // Regular expression to match title
}
Rule defines a single filter rule that can be applied to notifications. All fields are optional. When multiple fields are specified, all conditions must match (AND logic) for the rule to apply.
type ValueFilter ¶
type ValueFilter struct {
Any []string `yaml:"-"` // Patterns to match (glob-style). Empty means match all.
Not []string `yaml:"not"` // Patterns to exclude (glob-style)
}
ValueFilter specifies which values to include or exclude using patterns. Supports both simple list format and explicit include/exclude format.
Examples:
- Simple list: reasons: ["assigned", "mentioned"]
- With exclusions: repos: {any: ["org/*"], not: ["org/archived-*"]}
func (*ValueFilter) UnmarshalYAML ¶
func (vf *ValueFilter) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements custom YAML unmarshaling to support two formats:
- Simple list: reasons: ["assigned", "mention"]
- Object with any/not: repos: {any: ["org/*"], not: ["org/old-*"]}