Help us shape the future of Go! Take the 2026 Go Developer Survey

repo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package repo provides types for discovering local git repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandFinder

type CommandFinder struct {
	// Command is a shell command string executed via "sh -c".
	Command string
	// CommandFunc overrides command execution when set (useful in tests).
	CommandFunc func(ctx context.Context, command string) ([]byte, error)
}

CommandFinder runs an external command and treats each line of its stdout as an absolute repository path. CommandFunc can be replaced in tests to avoid real subprocess execution.

func (*CommandFinder) Find

func (f *CommandFinder) Find(ctx context.Context) ([]string, error)

type DirtyChecker

type DirtyChecker interface {
	IsDirty(ctx context.Context, dir string) (bool, error)
}

DirtyChecker determines if a repository at dir has uncommitted changes.

type FilesystemFinder

type FilesystemFinder struct {
	Root string
}

FilesystemFinder walks Root recursively and returns every directory that contains a ".git" entry (file or directory).

func (*FilesystemFinder) Find

func (f *FilesystemFinder) Find(ctx context.Context) ([]string, error)

type FilteredFinder

type FilteredFinder struct {
	Inner   Finder
	Pattern *regexp.Regexp
}

FilteredFinder wraps another Finder and keeps only paths that match Pattern. A nil Pattern passes all paths through.

func (*FilteredFinder) Find

func (f *FilteredFinder) Find(ctx context.Context) ([]string, error)

type Finder

type Finder interface {
	Find(ctx context.Context) ([]string, error)
}

Finder returns a list of absolute paths to local git repositories.

func NewFilteredFinder

func NewFilteredFinder(finder Finder, patterns []string) (Finder, error)

NewFilteredFinder wraps finder with a FilteredFinder using patterns. Multiple patterns are joined with "|" to form a single regexp. If patterns is empty, finder is returned as-is.

func NewFinder

func NewFinder(reposRoot, listRepos string) Finder

NewFinder constructs the appropriate Finder based on config values. If listRepos is non-empty, a CommandFinder is returned. Otherwise a FilesystemFinder rooted at reposRoot is returned.

func NewLimitedFinder

func NewLimitedFinder(finder Finder, limit int) Finder

NewLimitedFinder wraps finder with a LimitedFinder if limit > 0. If limit <= 0, finder is returned as-is.

func NewRemoteURLFilterFinder

func NewRemoteURLFilterFinder(finder Finder, checker RemoteURLChecker, pattern *regexp.Regexp) Finder

NewRemoteURLFilterFinder wraps finder with a RemoteURLFilterFinder if pattern is not nil.

func NewSortedFinder

func NewSortedFinder(finder Finder, sortAsc, sortDesc bool) Finder

NewSortedFinder wraps finder with a SortedFinder if sortAsc or sortDesc is true. If sortDesc is true, it takes precedence (or sorts in reverse order). If neither is true, finder is returned as-is.

func NewStatusFilterFinder

func NewStatusFilterFinder(finder Finder, checker DirtyChecker, dirtyOnly, cleanOnly bool) Finder

NewStatusFilterFinder wraps finder with a StatusFilterFinder if dirtyOnly or cleanOnly is true.

type LimitedFinder

type LimitedFinder struct {
	Inner Finder
	Limit int
}

LimitedFinder wraps another Finder and limits the number of returned repository paths to at most Limit paths from the beginning.

func (*LimitedFinder) Find

func (f *LimitedFinder) Find(ctx context.Context) ([]string, error)

type RemoteURLChecker

type RemoteURLChecker interface {
	RemoteURL(ctx context.Context, dir string) (string, error)
}

RemoteURLChecker determines the remote URL of a repository at dir.

type RemoteURLFilterFinder

type RemoteURLFilterFinder struct {
	Inner   Finder
	Checker RemoteURLChecker
	Pattern *regexp.Regexp
}

RemoteURLFilterFinder filters repositories based on whether their remote URL matches Pattern.

func (*RemoteURLFilterFinder) Find

func (f *RemoteURLFilterFinder) Find(ctx context.Context) ([]string, error)

type SortedFinder

type SortedFinder struct {
	Inner   Finder
	Reverse bool
}

SortedFinder wraps another Finder and sorts repository paths. If Reverse is true, paths are sorted in descending order; otherwise ascending.

func (*SortedFinder) Find

func (f *SortedFinder) Find(ctx context.Context) ([]string, error)

type StatusFilterFinder

type StatusFilterFinder struct {
	Inner     Finder
	Checker   DirtyChecker
	DirtyOnly bool // if true, only keep dirty repos
	CleanOnly bool // if true, only keep clean repos
}

StatusFilterFinder filters repositories based on whether they are dirty or clean.

func (*StatusFilterFinder) Find

func (f *StatusFilterFinder) Find(ctx context.Context) ([]string, error)

type StdinFinder

type StdinFinder struct {
	Reader io.Reader
}

StdinFinder reads repository paths (one per line) from Reader.

func (*StdinFinder) Find

func (f *StdinFinder) Find(ctx context.Context) ([]string, error)

Jump to

Keyboard shortcuts

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