consignment

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateMetadata

func AggregateMetadata(consignments []*Consignment) map[string]interface{}

AggregateMetadata collects all metadata fields from consignments If a field appears multiple times with different values, the last value wins

func CalculateDirectBumps

func CalculateDirectBumps(consignments []*Consignment) map[string]types.ChangeType

CalculateDirectBumps calculates the version bump for each package based on direct consignments Returns a map of package name to highest change type affecting that package

func DeleteConsignment

func DeleteConsignment(path string) error

DeleteConsignment deletes a single consignment file Returns error if file doesn't exist or deletion fails

func DeleteConsignmentByID

func DeleteConsignmentByID(consignmentsDir, id string) error

DeleteConsignmentByID deletes a consignment file by its ID Returns error if file doesn't exist or deletion fails

func DeleteConsignments

func DeleteConsignments(paths []string) error

DeleteConsignments deletes multiple consignment files Collects all errors instead of failing on first error

func DeleteConsignmentsByIDs

func DeleteConsignmentsByIDs(consignmentsDir string, ids []string) error

DeleteConsignmentsByIDs deletes multiple consignment files by their IDs Collects all errors instead of failing on first error

func GenerateID

func GenerateID(timestamp time.Time) (string, error)

GenerateID generates a unique consignment ID with format: YYYYMMDD-HHMMSS-random6 This is the main ID generation function that should be used for creating new consignments

func GenerateIDFromTime

func GenerateIDFromTime(timestamp time.Time) (string, error)

GenerateIDFromTime generates a unique consignment ID from a timestamp Format: YYYYMMDD-HHMMSS-{random6} Deprecated: Use GenerateID(timestamp) instead

func GetHighestChangeType

func GetHighestChangeType(consignments []*Consignment) types.ChangeType

GetHighestChangeType returns the highest priority change type from a list of consignments Priority: major > minor > patch

func GetUniquePackages

func GetUniquePackages(consignments []*Consignment) []string

GetUniquePackages returns a sorted list of unique package names from consignments

func GroupConsignmentsByChangeType

func GroupConsignmentsByChangeType(consignments []*Consignment) map[types.ChangeType][]*Consignment

GroupConsignmentsByChangeType groups consignments by their change type

func GroupConsignmentsByMetadataField

func GroupConsignmentsByMetadataField(consignments []*Consignment, fieldName string) map[string][]*Consignment

GroupConsignmentsByMetadataField groups consignments by a specific metadata field value Returns a map where keys are the field values (as strings) and values are consignment slices

func GroupConsignmentsByPackage

func GroupConsignmentsByPackage(consignments []*Consignment) map[string][]*Consignment

GroupConsignmentsByPackage groups consignments by package name A consignment affecting multiple packages will appear in multiple groups

func ReadAllConsignmentsWithErrors added in v0.4.0

func ReadAllConsignmentsWithErrors(dir string) ([]*Consignment, []ParseError, error)

ReadAllConsignmentsWithErrors reads all consignments and returns both successful parses and any parse errors (instead of failing on first error)

func Serialize

func Serialize(cons *Consignment) (string, error)

Serialize converts a consignment to markdown with YAML frontmatter

func WriteConsignment

func WriteConsignment(cons *Consignment, dir string) error

WriteConsignment writes a consignment to a markdown file with atomic write

Types

type Consignment

type Consignment struct {
	ID         string                 `yaml:"id"`
	Timestamp  time.Time              `yaml:"timestamp"`
	Packages   []string               `yaml:"packages"`
	ChangeType types.ChangeType       `yaml:"changeType"`
	Summary    string                 `yaml:"-"` // Stored in markdown body
	Metadata   map[string]interface{} `yaml:"metadata,omitempty"`
}

Consignment represents a recorded change to one or more packages

func FilterConsignmentsByPackage

func FilterConsignmentsByPackage(consignments []*Consignment, packageName string) []*Consignment

FilterConsignmentsByPackage returns consignments that affect the specified package

func GetConsignmentsByDateRange

func GetConsignmentsByDateRange(consignments []*Consignment, start, end *time.Time) []*Consignment

GetConsignmentsByDateRange filters consignments within a date range (inclusive) Both start and end times are optional (nil means no bound)

func New

func New(packages []string, changeType types.ChangeType, summary string, metadata map[string]interface{}) (*Consignment, error)

New creates a new Consignment with generated ID and timestamp

func ReadAllConsignments

func ReadAllConsignments(consignmentDir string) ([]*Consignment, error)

ReadAllConsignments reads all consignment files from a directory Returns a slice of Consignment structs sorted by timestamp (oldest first) Parse errors are logged to stderr but do not cause the function to fail

func ReadAllConsignmentsFiltered

func ReadAllConsignmentsFiltered(consignmentDir string, packageFilter []string) ([]*Consignment, error)

ReadAllConsignmentsFiltered reads consignments and filters by package names If packageFilter is nil or empty, returns all consignments

func ReadConsignment

func ReadConsignment(path string) (*Consignment, error)

ReadConsignment reads and parses a consignment file from the given path Returns a Consignment struct with parsed YAML frontmatter and markdown body

func SortConsignmentsByTimestamp

func SortConsignmentsByTimestamp(consignments []*Consignment) []*Consignment

SortConsignmentsByTimestamp returns a new slice sorted by timestamp (oldest first) Does not modify the input slice

func (*Consignment) AffectsPackage

func (c *Consignment) AffectsPackage(packageName string) bool

AffectsPackage checks if this consignment affects the specified package

func (*Consignment) Validate

func (c *Consignment) Validate() error

Validate checks if the consignment is valid

type ParseError added in v0.4.0

type ParseError struct {
	File    string
	Message string
	Err     error
}

ParseError represents a failure to parse a single consignment file

func (*ParseError) Error added in v0.4.0

func (e *ParseError) Error() string

func (*ParseError) Unwrap added in v0.4.0

func (e *ParseError) Unwrap() error

Jump to

Keyboard shortcuts

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