diff

package
v0.0.0-...-8929951 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountByType

func CountByType(changes []Change, changeType ChangeType) int

CountByType counts changes by type

func FormatLocation

func FormatLocation(location string) string

FormatLocation formats a location string for display

func GetMigrationTip

func GetMigrationTip(changeType ChangeType, location string) string

GetMigrationTip provides a migration tip based on change type

func IsBreaking

func IsBreaking(change Change) bool

Helper to check if a change is breaking

Types

type Analyzer

type Analyzer struct{}

Analyzer analyzes differences between proto file versions

func NewAnalyzer

func NewAnalyzer() *Analyzer

NewAnalyzer creates a new diff analyzer

func (*Analyzer) Compare

func (a *Analyzer) Compare(fromVersion, toVersion *api.Version) (*DiffResult, error)

Compare compares two versions and returns the differences

type Change

type Change struct {
	Type         ChangeType `json:"type"`
	Severity     Severity   `json:"severity"`
	Location     string     `json:"location"`
	OldValue     string     `json:"old_value,omitempty"`
	NewValue     string     `json:"new_value,omitempty"`
	Description  string     `json:"description"`
	MigrationTip string     `json:"migration_tip,omitempty"`
}

Change represents a single change between two versions

func FilterBySeverity

func FilterBySeverity(changes []Change, severity Severity) []Change

FilterBySeverity filters changes by severity

type ChangeType

type ChangeType string

ChangeType represents the type of change detected

const (
	FieldAdded         ChangeType = "field_added"
	FieldRemoved       ChangeType = "field_removed"
	FieldRenamed       ChangeType = "field_renamed"
	TypeChanged        ChangeType = "type_changed"
	MessageAdded       ChangeType = "message_added"
	MessageRemoved     ChangeType = "message_removed"
	EnumAdded          ChangeType = "enum_added"
	EnumRemoved        ChangeType = "enum_removed"
	EnumValueAdded     ChangeType = "enum_value_added"
	EnumValueRemoved   ChangeType = "enum_value_removed"
	ServiceAdded       ChangeType = "service_added"
	ServiceRemoved     ChangeType = "service_removed"
	MethodAdded        ChangeType = "method_added"
	MethodRemoved      ChangeType = "method_removed"
	FieldNumberChanged ChangeType = "field_number_changed"
	LabelChanged       ChangeType = "label_changed"
)

type DiffResult

type DiffResult struct {
	FromVersion string   `json:"from_version"`
	ToVersion   string   `json:"to_version"`
	Changes     []Change `json:"changes"`
}

DiffResult contains all changes detected between two versions

type Severity

type Severity string

Severity represents the severity level of a change

const (
	Breaking    Severity = "breaking"
	NonBreaking Severity = "non_breaking"
	Warning     Severity = "warning"
)

func GetSeverity

func GetSeverity(changeType ChangeType) Severity

GetSeverity determines the severity of a change based on its type

Jump to

Keyboard shortcuts

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