Documentation
¶
Overview ¶
Package version provides spec version tracking with git-like history.
Index ¶
- Variables
- func SaveHistory(projectPath string, history *History) error
- type CreateOptions
- type DiffLine
- type DiffResult
- type DiffType
- type History
- type Version
- func CreateVersion(projectPath string, specType types.SpecType, opts CreateOptions) (*Version, error)
- func GetLatestVersion(projectPath string, specType types.SpecType) (*Version, string, error)
- func GetVersion(projectPath string, specType types.SpecType, versionNum int) (*Version, string, error)
- func ListVersions(projectPath string, specType types.SpecType) ([]Version, error)
- func Revert(projectPath string, specType types.SpecType, versionNum int, message string) (*Version, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoChanges = fmt.Errorf("no changes since last version") ErrVersionNotFound = fmt.Errorf("version not found") ErrNoVersions = fmt.Errorf("no versions exist") )
Errors
Functions ¶
func SaveHistory ¶
SaveHistory persists the version history.
Types ¶
type CreateOptions ¶
CreateOptions configures version creation.
type DiffResult ¶
type DiffResult struct {
SpecType types.SpecType
OldVersion int
NewVersion int
Lines []DiffLine
Additions int
Deletions int
Unchanged int
}
DiffResult contains the diff between two versions.
func Diff ¶
func Diff(projectPath string, specType types.SpecType, oldVersion, newVersion int) (*DiffResult, error)
Diff compares two versions of a spec.
func DiffWithCurrent ¶
func DiffWithCurrent(projectPath string, specType types.SpecType, versionNum int) (*DiffResult, error)
DiffWithCurrent compares a version with the current spec file.
func (*DiffResult) FormatCompact ¶
func (d *DiffResult) FormatCompact() string
FormatCompact formats a diff in compact form (changes only).
func (*DiffResult) FormatDiff ¶
func (d *DiffResult) FormatDiff() string
FormatDiff formats a diff result for terminal output.
type DiffType ¶
type DiffType string
DiffType indicates whether a line was added, removed, or unchanged.
type History ¶
type History struct {
SpecType types.SpecType `json:"spec_type"`
Versions []Version `json:"versions"`
}
History tracks all versions of a spec.
type Version ¶
type Version struct {
Number int `json:"number"` // Sequential version number (1, 2, 3...)
Hash string `json:"hash"` // SHA256 of content
Timestamp time.Time `json:"timestamp"` // When version was created
Author string `json:"author,omitempty"` // Who created this version
Message string `json:"message,omitempty"` // Description of changes
Size int `json:"size"` // Content size in bytes
}
Version represents a specific version of a spec.
func CreateVersion ¶
func CreateVersion(projectPath string, specType types.SpecType, opts CreateOptions) (*Version, error)
CreateVersion creates a new version from the current spec content.
func GetLatestVersion ¶
GetLatestVersion returns the most recent version.
func GetVersion ¶
func GetVersion(projectPath string, specType types.SpecType, versionNum int) (*Version, string, error)
GetVersion retrieves a specific version.
func ListVersions ¶
ListVersions returns all versions for a spec.