ticket

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FieldRegistry = map[string]FieldSpec{

	"labels":     {Type: FieldTypeArray},
	"milestones": {Type: FieldTypeArray},
	"depends_on": {Type: FieldTypeArray},
	"blocks":     {Type: FieldTypeArray},
	"related":    {Type: FieldTypeArray},

	"points": {Type: FieldTypeInt},

	"id":         {Type: FieldTypeString},
	"title":      {Type: FieldTypeString},
	"assignee":   {Type: FieldTypeString},
	"parent":     {Type: FieldTypeString},
	"created_at": {Type: FieldTypeString},
	"updated_at": {Type: FieldTypeString},

	"status":   {Type: FieldTypeEnum},
	"type":     {Type: FieldTypeEnum, AllowedValues: []string{"epic", "story", "task", "bug"}},
	"priority": {Type: FieldTypeEnum, AllowedValues: []string{"low", "medium", "high", "critical"}},
}

FieldRegistry maps field names to their specifications

Functions

func AppendDomain

func AppendDomain(username, domain string) string

AppendDomain appends a domain suffix to a username if:

  • domain is non-empty
  • username does not already contain "@"

func CreateCommentFile

func CreateCommentFile(ticketID string, author string, body string, baseDir string) (string, error)

CreateCommentFile writes a new comment file Creates the ticket comment directory if it doesn't exist Returns the relative path to the created comment file

func GenerateCommentFilename

func GenerateCommentFilename(author string, timestamp time.Time) string

GenerateCommentFilename creates a filesystem-safe filename for a comment Format: {ISO8601-timestamp}-{author}.md Example: 2026-02-03T14-30-00Z-alice.md

func ParseFieldValue

func ParseFieldValue(fieldName, value string) (interface{}, error)

ParseFieldValue parses a string value according to the field's type

func RemoveRelationshipFromAllFields

func RemoveRelationshipFromAllFields(pmPath, sourceID, targetID string) (bool, error)

RemoveRelationshipFromAllFields removes a target ID from all relationship arrays in a ticket Used by pm unlink when no type is specified Returns (wasNotLinked, error)

func UpdateCommentFile

func UpdateCommentFile(commentPath string, body string, updatedAt time.Time) error

UpdateCommentFile updates an existing comment file with a new body and updated_at timestamp. It preserves the original author and created_at fields.

func UpdateRelationshipWithSymmetry

func UpdateRelationshipWithSymmetry(pmPath, sourceID, targetID, relType string, add bool) (bool, error)

UpdateRelationshipWithSymmetry manages array-based ticket relationships with automatic symmetry. For depends-on/blocks pairs, modifying one ticket automatically updates the inverse in the other. For related links, only the source ticket is modified.

Parameters:

  • sourceID: The ticket being modified (e.g., GPM-5)
  • targetID: The related ticket (e.g., GPM-10)
  • relType: Relationship type (depends-on, blocks, related)
  • add: true to add relationship, false to remove

Returns (alreadyExists, error):

  • alreadyExists: true if relationship already existed (for add operations)
  • error: if validation fails or file operations fail

On symmetry operation failure, rolls back the source ticket.

Types

type Comment

type Comment struct {
	Author    string    `yaml:"author"`
	CreatedAt time.Time `yaml:"-"` // Stored as ISO8601 string in YAML
	UpdatedAt time.Time `yaml:"-"` // Stored as ISO8601 string in YAML
	Body      string    `yaml:"-"`
	Path      string    `yaml:"-"`
}

Comment represents a single comment on a ticket.

func ListCommentsForTicket

func ListCommentsForTicket(ticketID string, baseDir string) ([]*Comment, error)

ListCommentsForTicket returns all comments for a ticket, sorted by created_at ascending

func ParseCommentFile

func ParseCommentFile(filepath string) (*Comment, error)

ParseCommentFile reads and parses a comment file Returns the metadata and body content separately

type CommentMetadata

type CommentMetadata struct {
	Author    string `yaml:"author"`
	Timestamp string `yaml:"timestamp,omitempty"`  // Legacy ISO8601 format
	CreatedAt string `yaml:"created_at,omitempty"` // ISO8601 format
	UpdatedAt string `yaml:"updated_at,omitempty"` // ISO8601 format
}

CommentMetadata is the YAML front-matter of a comment file

type FieldSpec

type FieldSpec struct {
	Type          FieldType
	AllowedValues []string // For enum fields
}

FieldSpec defines the specification for a ticket field

type FieldType

type FieldType int

FieldType represents the data type of a ticket field

const (
	FieldTypeString FieldType = iota
	FieldTypeInt
	FieldTypeArray
	FieldTypeEnum
)

type Ticket

type Ticket struct {
	ID         string   `yaml:"id"`
	Title      string   `yaml:"title"`
	Type       string   `yaml:"type"`
	Status     string   `yaml:"status"`
	Priority   string   `yaml:"priority,omitempty"`
	Points     int      `yaml:"points,omitempty"`
	Parent     string   `yaml:"parent,omitempty"`
	DependsOn  []string `yaml:"depends_on,omitempty"`
	Blocks     []string `yaml:"blocks,omitempty"`
	Related    []string `yaml:"related,omitempty"`
	Labels     []string `yaml:"labels,omitempty"`
	Milestones []string `yaml:"milestones,omitempty"`
	Assignee   string   `yaml:"assignee,omitempty"`
	CreatedAt  string   `yaml:"created_at"`
	UpdatedAt  string   `yaml:"updated_at"`
	Body       string   `yaml:"-"`
}

func Parse

func Parse(content []byte) (*Ticket, error)

func (*Ticket) Normalize

func (t *Ticket) Normalize()

Normalize de-duplicates all array fields to maintain data integrity. Silent normalization - no errors, just cleans the data. Should be called before every save operation.

func (*Ticket) Validate

func (t *Ticket) Validate() error

Jump to

Keyboard shortcuts

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