repoinfo

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package repoinfo characterizes a repository from local git commands only (no network). It powers the `zero repo-info` command.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotGitRepo = errors.New("not a git repository, or it has no commits yet")

ErrNotGitRepo is returned when the directory is not a git repository or HEAD has no commits (git ls-tree against HEAD fails).

Functions

This section is empty.

Types

type Info

type Info struct {
	FileCount             int        `json:"fileCount"`
	DirectoryCount        int        `json:"directoryCount"`
	MaxDepth              int        `json:"maxDepth"`
	LOCEstimate           int        `json:"locEstimate"`
	Languages             []LangStat `json:"languages"`
	PrimaryLanguage       string     `json:"primaryLanguage,omitempty"`
	LanguageCount         int        `json:"languageCount"`
	WorkspaceType         string     `json:"workspaceType"`
	WorkspacePackageCount int        `json:"workspacePackageCount"`
	BuildTools            []string   `json:"buildTools"`
	TestTools             []string   `json:"testTools"`
	CICD                  []string   `json:"cicd"`
	HasGit                bool       `json:"hasGit"`
	Branch                string     `json:"branch,omitempty"`
	RemoteURL             string     `json:"remoteURL,omitempty"`
	AgeDays               *int       `json:"ageDays,omitempty"`
	Contributors90d       *int       `json:"contributors90d,omitempty"`
	CommitVelocity30d     *int       `json:"commitVelocity30d,omitempty"`
	BranchCount           *int       `json:"branchCount,omitempty"`
	CommitCount           *int       `json:"commitCount,omitempty"`
	TagCount              *int       `json:"tagCount,omitempty"`
}

Info is the collected repository characterization.

func Collect

func Collect(ctx context.Context, opts Options) (Info, error)

Collect gathers repository metadata from local git only. It never performs a network operation. Returns ErrNotGitRepo when the directory has no readable HEAD tree; individual history metrics fail soft (omitted, not fatal).

type LangStat

type LangStat struct {
	Name        string `json:"name"`
	LOCEstimate int    `json:"locEstimate"`
	FileCount   int    `json:"fileCount"`
}

LangStat is a per-language rollup.

type Options

type Options struct {
	Cwd    string
	Now    time.Time
	RunGit RunGit
}

Options configures Collect. Now and RunGit are injectable for tests.

type RunGit

type RunGit func(ctx context.Context, dir string, args ...string) (string, error)

RunGit runs a git subcommand in dir and returns raw stdout. A non-zero exit (or spawn failure) MUST return a non-nil error.

Jump to

Keyboard shortcuts

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