storage

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateFeatureFilename

func GenerateFeatureFilename(name, id string, existingFiles map[string]bool) string

GenerateFeatureFilename generates a filename from feature name and ID, handling collisions This is exported so callers can know what filename will be used

func MarshalFeature

func MarshalFeature(feature *fogit.Feature) ([]byte, error)

MarshalFeature serializes a feature to YAML bytes

func ReadFeatureFile

func ReadFeatureFile(path string) (*fogit.Feature, error)

ReadFeatureFile reads a feature from a YAML file

func Slugify

func Slugify(text string, opts SlugifyOptions) string

Slugify converts text to a URL-safe slug with configurable options

func UnmarshalFeature

func UnmarshalFeature(data []byte) (*fogit.Feature, error)

UnmarshalFeature deserializes YAML bytes to a feature

func WriteFeatureFile

func WriteFeatureFile(path string, feature *fogit.Feature) error

WriteFeatureFile writes a feature to a YAML file atomically It writes to a temp file first, then renames to ensure atomicity

Types

type FileRepository

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

FileRepository implements fogit.Repository using YAML files

func NewFileRepository

func NewFileRepository(basePath string) *FileRepository

NewFileRepository creates a new file-based repository

func (*FileRepository) Create

func (r *FileRepository) Create(ctx context.Context, feature *fogit.Feature) error

Create creates a new feature in the repository

func (*FileRepository) Delete

func (r *FileRepository) Delete(ctx context.Context, id string) error

Delete removes a feature from the repository

func (*FileRepository) Get

func (r *FileRepository) Get(ctx context.Context, id string) (*fogit.Feature, error)

Get retrieves a feature by ID

func (*FileRepository) List

func (r *FileRepository) List(ctx context.Context, filter *fogit.Filter) ([]*fogit.Feature, error)

List retrieves features matching the given filter

func (*FileRepository) Update

func (r *FileRepository) Update(ctx context.Context, feature *fogit.Feature) error

Update updates an existing feature

type IDIndex

type IDIndex struct {
	// Entries maps feature ID to filename (e.g., "550e8400..." -> "user-authentication.yml")
	Entries map[string]string `json:"entries"`
	// contains filtered or unexported fields
}

IDIndex provides O(1) lookup from feature ID to filename. This is stored in .fogit/metadata/id_index.json

func NewIDIndex

func NewIDIndex(basePath string) *IDIndex

NewIDIndex creates a new ID index for the given .fogit directory

func (*IDIndex) Delete

func (idx *IDIndex) Delete(id string)

Delete removes an ID from the index

func (*IDIndex) Get

func (idx *IDIndex) Get(id string) string

Get returns the filename for a given ID, or empty string if not found

func (*IDIndex) Has

func (idx *IDIndex) Has(id string) bool

Has checks if an ID exists in the index

func (*IDIndex) Load

func (idx *IDIndex) Load() error

Load reads the index from disk. If the file doesn't exist, returns an empty index.

func (*IDIndex) Rebuild

func (idx *IDIndex) Rebuild(featuresDir string) error

Rebuild reconstructs the index by scanning all feature files. This is useful for recovery or initial setup.

func (*IDIndex) Save

func (idx *IDIndex) Save() error

Save writes the index to disk atomically

func (*IDIndex) Set

func (idx *IDIndex) Set(id, filename string)

Set adds or updates an ID -> filename mapping

type SlugifyOptions

type SlugifyOptions struct {
	MaxLength        int    // Maximum length (default: 100)
	AllowSlashes     bool   // Allow forward slashes (for branch names)
	NormalizeUnicode bool   // Remove accents/diacritics
	EmptyFallback    string // Fallback for empty slugs
}

SlugifyOptions configures slug generation behavior

func DefaultSlugifyOptions

func DefaultSlugifyOptions() SlugifyOptions

DefaultSlugifyOptions returns options for filename slugs

Jump to

Keyboard shortcuts

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