commitref

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package commitref parses commit messages for task references (bare #N, keyword refs, and slug#N cross-project refs) and maps action keywords to task statuses. Parsing is split into a chain of internal parsers sharing per-message dedup state; the package is provided as a service so every consumer shares the same configured keyword table.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyKeyword     = errors.New("must not be empty")
	ErrInvalidStatus    = errors.New("invalid keyword status")
	ErrDuplicateKeyword = errors.New("duplicate keyword")
)

Functions

func Module

func Module() fx.Option

Module creates and returns an FX module for the commitref package.

The module provides:

  • commitref.Service (public) - for use by other modules that scan commit messages

Types

type Config

type Config struct {
	// ActionKeywords maps a commit message keyword to the task status
	// transition it triggers.
	ActionKeywords map[string]KeywordEntry
}

Config holds the settings for parsing commit messages.

type KeywordAction

type KeywordAction struct {
	Status tasks.Status // target status
	Verb   string       // past-tense label for comment, e.g. "Resolved"
}

KeywordAction maps a commit message keyword to a task status transition.

type KeywordEntry

type KeywordEntry struct {
	Status string `json:"status"`
	Verb   string `json:"verb"`
}

type ParsedReference

type ParsedReference struct {
	TaskNumber    int
	ProjectSlug   string         // empty means the current project
	Action        *KeywordAction // nil if bare #N with no keyword
	CommitHash    string
	CommitMessage string
}

ParsedReference represents a single task reference found in a commit message.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service parses commit messages for task references by running an ordered chain of parsers over shared per-message state.

func NewService

func NewService(cfg Config) (*Service, error)

NewService builds a Service from cfg. It validates every keyword status, rejects keywords that collide after case normalization, and compiles the keyword matcher from the sorted keyword list. An invalid configuration is returned as an error so the app fails at startup instead of silently ignoring commit references. An empty ActionKeywords map leaves the keyword matcher uncompiled: the chain then runs in mentions-only mode, so bare #N and slug#N references still parse but no keyword carries a status transition.

func (*Service) ParseCommitMessage

func (s *Service) ParseCommitMessage(message string) []ParsedReference

ParseCommitMessage scans a commit message for task references. Returns a list of ParsedReference, one per unique (slug, number) pair found. A reference may carry an optional project-slug prefix (e.g. "resto-web#13"); a bare "#NUMBER" keeps ProjectSlug == "" and refers to the current project. Parsers run in precedence order (keyword, prefixed, bare); if both a keyword and bare reference exist for the same (slug, number), the keyword wins.

Jump to

Keyboard shortcuts

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