scanner

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpConfig

func DumpConfig(config *Config) error

func GoGitStatus

func GoGitStatus(d string) (git.Status, error)

GoGitStatus uses go-git package to determine the git status for a directory.

func Walk

func Walk(ctx context.Context, config *Config, results chan string, onRepoFound func(string)) error

Walk finds all git repositories in the directories specified in config. onRepoFound is invoked once per discovered repository (from walker goroutines); nil is safe.

Types

type BranchLocation added in v1.0.0

type BranchLocation struct {
	Name             string
	Ref              string
	Exists           bool
	TipHash          string
	TipUnix          int64
	UniqueCount      int
	NewestUniqueUnix int64
	// Incoming/Outgoing compare this ref to the local branch ref only (remote
	// rows). Incoming is commits reachable from this remote but not local (+N);
	// Outgoing is commits on local not reachable from this remote (UI: -M).
	Incoming int
	Outgoing int
	// HistoriesUnrelated means git found no merge base between local and this
	// remote tip; the UI shows "differs" instead of numeric deltas.
	HistoriesUnrelated bool
}

type BranchStatus added in v1.0.0

type BranchStatus struct {
	Branch         string
	Detached       bool
	Locations      []BranchLocation
	NewestLocation string
	// LocalBranches lists refs/heads in name order (from git for-each-ref).
	LocalBranches []LocalBranchRef
}

func GitBranchStatus added in v1.0.0

func GitBranchStatus(d string) (BranchStatus, error)

func (BranchStatus) HasLocalRemoteMismatch added in v1.0.0

func (b BranchStatus) HasLocalRemoteMismatch() bool

HasLocalRemoteMismatch reports whether the current local branch differs from any tracked remote location for the same branch name.

type Config

type Config struct {
	ScanDirs struct {
		Include []string `yaml:"include"`
		Exclude []string `yaml:"exclude"`
	} `yaml:"scandirs"`
	GitIgnore struct {
		FileGlob []string `yaml:"fileglob"`
		DirGlob  []string `yaml:"dirglob"`
	} `yaml:"gitignore"`
	FollowSymlinks bool `yaml:"followsymlinks"`
	Branches       struct {
		HideLocalOnly struct {
			Regex []string `yaml:"regex"`
		} `yaml:"hidelocalonly"`
		// Default lists branch short names always shown in the branch pane when
		// present as a local ref, even when tips match every remote.
		Default []string `yaml:"default"`
	} `yaml:"branches"`
	// Edit holds argv for opening a repository from the UI (key "e").
	Edit struct {
		// Command is the program and arguments passed to exec (no shell).
		// Use the literal substring "{repo}" in any element to substitute the
		// absolute repository path. If no element contains "{repo}", the path
		// is appended as the final argument. Empty means ["code", <repo>].
		Command []string `yaml:"command"`
	} `yaml:"edit"`
	// contains filtered or unexported fields
}

func ParseConfigFile

func ParseConfigFile(filename, defaultConfig string) (*Config, error)

func (*Config) AlwaysListBranch added in v1.0.0

func (c *Config) AlwaysListBranch(name string) bool

AlwaysListBranch reports whether name is listed under branches.default (after trim); those branches are listed in the pane whenever they exist locally, regardless of remote tip agreement.

func (*Config) EditArgv added in v1.0.0

func (c *Config) EditArgv(absRepo string) ([]string, error)

EditArgv returns the argv for opening absRepo in an external editor or IDE. See Config.Edit.Command for placeholder and default behavior.

func (*Config) ShouldHideLocalOnlyBranch added in v1.0.0

func (c *Config) ShouldHideLocalOnlyBranch(lb LocalBranchRef) bool

ShouldHideLocalOnlyBranch returns true when lb is local-only (see LocalBranchRef.IsLocalOnly) and its short branch name matches any pattern in branches.hidelocalonly.regex.

type Excluder

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

func NewExcluder

func NewExcluder(files, dirs []string) (Excluder, error)

func (Excluder) FilterGitStatus

func (e Excluder) FilterGitStatus(st git.Status) git.Status

func (Excluder) FilterPorcelainStatus added in v1.0.0

func (e Excluder) FilterPorcelainStatus(st PorcelainStatus) PorcelainStatus

func (Excluder) IsExcluded

func (e Excluder) IsExcluded(path string) bool

type LocalBranchRef added in v1.0.0

type LocalBranchRef struct {
	Name      string
	TipHash   string
	TipUnix   int64
	Current   bool
	Locations []BranchLocation
}

LocalBranchRef is one local branch tip (refs/heads/*). Locations holds local vs same-named remote refs (refs/remotes/<remote>/<name>); it is empty when detached or before GitBranchStatus fills it.

func (LocalBranchRef) HasTipMismatchAcrossRemotes added in v1.0.0

func (lb LocalBranchRef) HasTipMismatchAcrossRemotes() bool

HasTipMismatchAcrossRemotes reports whether the branch should appear in the branch pane: true when Locations is empty (e.g. detached), there are no configured remotes, any same-named remote ref is missing, or any remote tip differs from the local tip. False only when every remote has the ref and each tip matches local.

func (LocalBranchRef) IsLocalOnly added in v1.0.0

func (lb LocalBranchRef) IsLocalOnly() bool

IsLocalOnly reports whether no configured remote has a same-named branch ref (refs/remotes/<remote>/<name> missing for every remote). Repositories with no remotes still populate only the local slot, which counts as local-only here. Empty Locations (e.g. some detached listings) yields false so branches are not classified without remote comparison data.

type MultiGitStatus

type MultiGitStatus map[string]RepoStatus

func Scan

func Scan(config *Config) (MultiGitStatus, error)

Scan finds all "dirty" git repositories specified by config.

func ScanWithProgress added in v1.0.0

func ScanWithProgress(config *Config, onProgress func(ScanProgress)) (MultiGitStatus, error)

ScanWithProgress runs the same scan as Scan and invokes onProgress from concurrent discovery and the status loop. Callbacks should be non-blocking (e.g. small channel send).

type PorcelainEntry added in v1.0.0

type PorcelainEntry struct {
	Staging      git.StatusCode
	Worktree     git.StatusCode
	Path         string
	OriginalPath string
}

type PorcelainStatus added in v1.0.0

type PorcelainStatus struct {
	Entries []PorcelainEntry
}

func GitStatus

func GitStatus(d string) (PorcelainStatus, error)

GitStatus invokes git executable to determine the git status for a directory.

func ParsePorcelainStatus added in v1.0.0

func ParsePorcelainStatus(r io.Reader) (PorcelainStatus, error)

func (PorcelainStatus) ToGitStatus added in v1.0.0

func (p PorcelainStatus) ToGitStatus() git.Status

type RepoStatus

type RepoStatus struct {
	git.Status

	Porcelain PorcelainStatus
	Branches  BranchStatus
	ScanTime  time.Duration
}

func StatusForRepo added in v1.0.0

func StatusForRepo(config *Config, dir string) (RepoStatus, bool, error)

StatusForRepo returns fresh status for a single repository directory using the same porcelain filtering and branch metadata as ScanWithProgress. The bool is whether this repo should appear in the dirty list (!clean or remote mismatch).

type ScanProgress added in v1.0.0

type ScanProgress struct {
	ReposFound   int
	ReposChecked int
	CurrentPath  string
}

ScanProgress reports coarse scan activity for UIs (discovery vs git status). ReposFound may increase while ReposChecked catches up; both match the final total when complete.

Jump to

Keyboard shortcuts

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