Documentation
¶
Overview ¶
Package repo provides types for discovering local git repositories.
Index ¶
- type BranchChecker
- type BranchFilterFinder
- type CommandFinder
- type DefaultBranchFilterFinder
- type DirtyChecker
- type FilesystemFinder
- type FilteredFinder
- type Finder
- func NewBranchFilterFinder(finder Finder, checker BranchChecker, pattern *regexp.Regexp) Finder
- func NewDefaultBranchFilterFinder(finder Finder, checker BranchChecker, defaultOnly, notDefaultOnly bool) Finder
- func NewFilteredFinder(finder Finder, patterns []string) (Finder, error)
- func NewFinder(reposRoot, listRepos string) Finder
- func NewLimitedFinder(finder Finder, limit int) Finder
- func NewRemoteURLFilterFinder(finder Finder, checker RemoteURLChecker, pattern *regexp.Regexp) Finder
- func NewSortedFinder(finder Finder, sortAsc, sortDesc bool) Finder
- func NewStatusFilterFinder(finder Finder, checker DirtyChecker, dirtyOnly, cleanOnly bool) Finder
- type LimitedFinder
- type RemoteURLChecker
- type RemoteURLFilterFinder
- type SortedFinder
- type StatusFilterFinder
- type StdinFinder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BranchChecker ¶ added in v0.2.0
type BranchChecker interface {
CurrentBranch(ctx context.Context, dir string) (string, error)
ResolveDefaultBranch(ctx context.Context, dir string) (string, error)
}
BranchChecker determines the current branch and default branch of a repository at dir.
type BranchFilterFinder ¶ added in v0.2.0
type BranchFilterFinder struct {
Inner Finder
Checker BranchChecker
Pattern *regexp.Regexp
}
BranchFilterFinder filters repositories based on whether their current branch matches Pattern.
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.
type DefaultBranchFilterFinder ¶ added in v0.2.0
type DefaultBranchFilterFinder struct {
Inner Finder
Checker BranchChecker
DefaultOnly bool
NotDefaultOnly bool
}
DefaultBranchFilterFinder filters repositories based on whether their current branch is the default branch (DefaultOnly) or not the default branch (NotDefaultOnly).
type DirtyChecker ¶
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).
type FilteredFinder ¶
FilteredFinder wraps another Finder and keeps only paths that match Pattern. A nil Pattern passes all paths through.
type Finder ¶
Finder returns a list of absolute paths to local git repositories.
func NewBranchFilterFinder ¶ added in v0.2.0
func NewBranchFilterFinder(finder Finder, checker BranchChecker, pattern *regexp.Regexp) Finder
NewBranchFilterFinder wraps finder with a BranchFilterFinder if pattern is not nil.
func NewDefaultBranchFilterFinder ¶ added in v0.2.0
func NewDefaultBranchFilterFinder(finder Finder, checker BranchChecker, defaultOnly, notDefaultOnly bool) Finder
NewDefaultBranchFilterFinder wraps finder with a DefaultBranchFilterFinder if defaultOnly or notDefaultOnly is true.
func NewFilteredFinder ¶
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 ¶
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 ¶
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 ¶
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 ¶
LimitedFinder wraps another Finder and limits the number of returned repository paths to at most Limit paths from the beginning.
type RemoteURLChecker ¶
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.
type SortedFinder ¶
SortedFinder wraps another Finder and sorts repository paths. If Reverse is true, paths are sorted in descending order; otherwise ascending.
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.