internal

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingRepo    = errors.New("repository path is required")
	ErrMissingTag1    = errors.New("first tag name is required")
	ErrMissingTag2    = errors.New("second tag name is required")
	ErrInvalidRepo    = errors.New("invalid repository path")
	ErrTag1NotFound   = errors.New("first tag not found in repository")
	ErrTag2NotFound   = errors.New("second tag not found in repository")
	ErrInvalidCommand = errors.New("invalid command")
	ErrNoCommand      = errors.New("no command specified")
)
View Source
var (
	ErrInvalidConfiguration = errors.New("invalid configuration")
	ErrValidationFailed     = errors.New("validation failed")
	ErrGetTagReference      = errors.New("failed to get tag reference")
	ErrGetCommits           = errors.New("failed to get commits")
	ErrInvalidDirectory     = errors.New("invalid directory path")
)
View Source
var (
	ErrConfigNotFound    = errors.New("config file not found")
	ErrInvalidProvider   = errors.New("invalid AI provider")
	ErrMissingAPIKey     = errors.New("API key is required")
	ErrConfigDirCreation = errors.New("failed to create config directory")
	ErrConfigFileWrite   = errors.New("failed to write config file")
	ErrConfigFileRead    = errors.New("failed to read config file")
	ErrInvalidConfigData = errors.New("invalid config data")
)
View Source
var (
	ErrReportGeneration = errors.New("failed to generate report")
	ErrAPIRequest       = errors.New("API request failed")
	ErrReportWrite      = errors.New("failed to write report file")
)
View Source
var (
	ErrOpenRepository  = errors.New("failed to open repository")
	ErrFetchTags       = errors.New("failed to fetch tags")
	ErrGetCommit       = errors.New("failed to get commit")
	ErrDereferenceTag  = errors.New("failed to dereference tag")
	ErrTraverseCommits = errors.New("failed to traverse commits")
)

Functions

func CalculateJaccardSimilarity

func CalculateJaccardSimilarity(setA map[plumbing.Hash]struct{}, setB map[plumbing.Hash]struct{}) float64

CalculateJaccardSimilarity computes the Jaccard similarity coefficient between two commit sets Returns a value between 0.0 and 1.0, where 1.0 means identical sets

func GenerateReport added in v1.2.0

func GenerateReport(result CompareResult, reportPath string) error

GenerateReport creates an AI-generated markdown report analyzing the tag differences

func GetCommitMessages added in v1.2.0

func GetCommitMessages(repo Repository, commits map[plumbing.Hash]struct{}) ([]string, error)

GetCommitMessages returns commit messages for a set of commit hashes

func GetConfigPath added in v1.2.0

func GetConfigPath() (string, error)

GetConfigPath returns the path to the config file

func GetDefaultModel added in v1.2.0

func GetDefaultModel(provider string) string

GetDefaultModel returns the default model for a given provider

func PrintCompareResult added in v0.1.3

func PrintCompareResult(result CompareResult)

func PrintUsage

func PrintUsage()

PrintUsage prints the main usage information

func PrintVersion

func PrintVersion()

PrintVersion prints the version information retrieved from the binary's build info

func RunConfigCommand added in v1.2.0

func RunConfigCommand(cmdConfig ConfigCommandConfig) error

RunConfigCommand executes the config command

func SaveConfig added in v1.2.0

func SaveConfig(config *AIConfig) error

SaveConfig saves the AI configuration to disk

Types

type AIConfig added in v1.2.0

type AIConfig struct {
	Provider AIProvider `json:"provider"`
	APIKey   string     `json:"api_key"`
	Model    string     `json:"model"`
}

AIConfig stores AI-related configuration

func LoadConfig added in v1.2.0

func LoadConfig() (*AIConfig, error)

LoadConfig loads the AI configuration from disk

func (*AIConfig) Validate added in v1.2.0

func (c *AIConfig) Validate() error

Validate checks if the config is valid

type AIProvider added in v1.2.0

type AIProvider string

AIProvider represents supported AI providers

const (
	ProviderClaude AIProvider = "claude"
	ProviderOpenAI AIProvider = "openai"
	ProviderGemini AIProvider = "gemini"
)

type ClaudeMessage added in v1.2.0

type ClaudeMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

ClaudeMessage represents a message in the Claude API

type ClaudeRequest added in v1.2.0

type ClaudeRequest struct {
	Model     string          `json:"model"`
	MaxTokens int             `json:"max_tokens"`
	Messages  []ClaudeMessage `json:"messages"`
}

ClaudeRequest represents a request to the Claude API

type ClaudeResponse added in v1.2.0

type ClaudeResponse struct {
	Content []struct {
		Type string `json:"type"`
		Text string `json:"text"`
	} `json:"content"`
	Error *struct {
		Type    string `json:"type"`
		Message string `json:"message"`
	} `json:"error,omitempty"`
}

ClaudeResponse represents a response from the Claude API

type Command

type Command string

Command represents the CLI command type

const (
	CompareCommand Command = "compare"
	ConfigCommand  Command = "config"
	HelpCommand    Command = "help"
	VersionCommand Command = "version"
)

func ParseCommand

func ParseCommand(args []string) (Command, error)

ParseCommand parses command-line arguments and returns the configuration

type CompareConfig added in v0.1.3

type CompareConfig struct {
	Command    Command
	RepoPath   string
	Tag1Name   string
	Tag2Name   string
	Directory  string
	Verbose    bool
	ReportPath string
}

CompareConfig holds the application configuration from command-line arguments

func NewCompareConfig added in v0.1.3

func NewCompareConfig(args []string) (CompareConfig, error)

NewCompareConfig parses the compare command flags

func (*CompareConfig) GetTagReference added in v0.1.3

func (c *CompareConfig) GetTagReference(repo Repository, tagName string) (*plumbing.Reference, error)

GetTagReference finds and returns the reference for a specific tag name

func (*CompareConfig) Validate added in v0.1.3

func (c *CompareConfig) Validate() error

Validate checks if the configuration is valid

func (*CompareConfig) ValidateWithRepository added in v0.1.3

func (c *CompareConfig) ValidateWithRepository(repo Repository) error

ValidateWithRepository checks if both tags exist in the repository

type CompareResult added in v0.1.3

type CompareResult struct {
	Repo          Repository
	Config        CompareConfig
	Tag1Ref       *plumbing.Reference
	Tag2Ref       *plumbing.Reference
	Similarity    float64
	SharedCommits map[plumbing.Hash]struct{}
	OnlyInTag1    map[plumbing.Hash]struct{}
	OnlyInTag2    map[plumbing.Hash]struct{}
	DiffStat      string
}

func Compare added in v0.1.3

func Compare(config CompareConfig) (CompareResult, error)

type ConfigCommandConfig added in v1.2.0

type ConfigCommandConfig struct {
	Provider string
	APIKey   string
	Model    string
}

ConfigCommandConfig holds the config command configuration

func NewConfigCommandConfig added in v1.2.0

func NewConfigCommandConfig(args []string) (ConfigCommandConfig, error)

NewConfigCommandConfig parses the config command flags

func (*ConfigCommandConfig) Validate added in v1.2.0

func (c *ConfigCommandConfig) Validate() error

Validate checks if the config command configuration is valid

type GeminiContent added in v1.2.0

type GeminiContent struct {
	Parts []struct {
		Text string `json:"text"`
	} `json:"parts"`
	Role string `json:"role,omitempty"`
}

Gemini API structures

type GeminiRequest added in v1.2.0

type GeminiRequest struct {
	Contents []GeminiContent `json:"contents"`
}

type GeminiResponse added in v1.2.0

type GeminiResponse struct {
	Candidates []struct {
		Content struct {
			Parts []struct {
				Text string `json:"text"`
			} `json:"parts"`
		} `json:"content"`
	} `json:"candidates"`
	Error *struct {
		Message string `json:"message"`
		Code    int    `json:"code"`
	} `json:"error,omitempty"`
}

type GitRepository

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

GitRepository is a concrete implementation of Repository using go-git

func NewGitRepository

func NewGitRepository(path string) (*GitRepository, error)

NewGitRepository creates a new GitRepository instance

func (*GitRepository) FetchAllTags

func (gr *GitRepository) FetchAllTags() ([]*plumbing.Reference, error)

FetchAllTags retrieves all tag references from the repository

func (*GitRepository) GetCommitObject

func (gr *GitRepository) GetCommitObject(hash plumbing.Hash) (*object.Commit, error)

GetCommitObject retrieves a commit object by its hash

func (*GitRepository) GetCommitSetForTag

func (gr *GitRepository) GetCommitSetForTag(ref *plumbing.Reference) (map[plumbing.Hash]struct{}, error)

GetCommitSetForTag traverses the history of a tag and returns all parent commit hashes. Handles both annotated tags (tag objects) and lightweight tags (direct commit refs).

func (*GitRepository) GetCommitSetForTagFilteredByDirectory added in v1.1.0

func (gr *GitRepository) GetCommitSetForTagFilteredByDirectory(ref *plumbing.Reference, directory string) (map[plumbing.Hash]struct{}, error)

GetCommitSetForTagFilteredByDirectory traverses the history of a tag and returns commits that touch files in the specified directory. Handles both annotated tags (tag objects) and lightweight tags (direct commit refs). Uses native git log command for performance (go-git's PathFilter is extremely slow).

func (*GitRepository) GetDiffBetweenTags added in v1.2.0

func (gr *GitRepository) GetDiffBetweenTags(tag1 *plumbing.Reference, tag2 *plumbing.Reference, directory string) (string, error)

GetDiffBetweenTags returns the diff between two tags. Handles both annotated tags (tag objects) and lightweight tags (direct commit refs). If directory is specified, only shows diff for files in that directory.

type OpenAIMessage added in v1.2.0

type OpenAIMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

OpenAI API structures

type OpenAIRequest added in v1.2.0

type OpenAIRequest struct {
	Model    string          `json:"model"`
	Messages []OpenAIMessage `json:"messages"`
}

type OpenAIResponse added in v1.2.0

type OpenAIResponse struct {
	Choices []struct {
		Message struct {
			Content string `json:"content"`
		} `json:"message"`
	} `json:"choices"`
	Error *struct {
		Message string `json:"message"`
		Type    string `json:"type"`
	} `json:"error,omitempty"`
}

type Repository

type Repository interface {
	FetchAllTags() ([]*plumbing.Reference, error)
	GetCommitSetForTag(ref *plumbing.Reference) (map[plumbing.Hash]struct{}, error)
	GetCommitSetForTagFilteredByDirectory(ref *plumbing.Reference, directory string) (map[plumbing.Hash]struct{}, error)
	GetCommitObject(hash plumbing.Hash) (*object.Commit, error)
	GetDiffBetweenTags(tag1 *plumbing.Reference, tag2 *plumbing.Reference, directory string) (string, error)
}

Repository is an interface that abstracts Git operations for testability

Jump to

Keyboard shortcuts

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