Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBreakdown ¶
func FormatBreakdown(breakdown []LanguageBreakdown) string
FormatBreakdown formats a language breakdown slice into a human-readable string. Example output: "Go: 12345 bytes (67%) | Python: 5678 bytes (33%)"
func GetHeadCommit ¶
GetHeadCommit returns the HEAD commit SHA for a git repository.
func LanguageForFile ¶
LanguageForFile returns the language name for a given file path, or empty string if the file type is not recognized. It checks exact filename first, then falls back to extension matching.
Types ¶
type LanguageBreakdown ¶
type LanguageBreakdown struct {
Name string `json:"name"`
Size int64 `json:"size"`
Percent int `json:"percent"` // floor of (size/total * 100)
}
LanguageBreakdown represents one language's share of a repository.
func DetectLanguages ¶
func DetectLanguages(repoPath string) ([]LanguageBreakdown, error)
DetectLanguages analyzes a git repository at the given path and returns a sorted list of language breakdowns (most bytes first). It uses `git ls-tree -r -l HEAD` to enumerate tracked files with their sizes.
func ParseLsTree ¶
func ParseLsTree(output string) ([]LanguageBreakdown, error)
ParseLsTree parses the output of `git ls-tree -r -l HEAD` and returns language breakdowns. Exported for testability.
Each line has the format:
<mode> <type> <hash> <size>\t<path>
Example:
100644 blob abc123 1234\tmain.go