Documentation
¶
Index ¶
- func RepoInclusionReasons(rs RepoStatus) []string
- func Walk(ctx context.Context, config *Config, results chan string, ...) error
- type BranchLocation
- type BranchStatus
- type Config
- type Excluder
- type LocalBranchRef
- type MultiGitStatus
- func (m *MultiGitStatus) AddResult(path string, rs RepoStatus)
- func (m *MultiGitStatus) Delete(path string)
- func (m *MultiGitStatus) Get(path string) (RepoStatus, bool)
- func (m *MultiGitStatus) Len() int
- func (m *MultiGitStatus) Set(path string, rs RepoStatus)
- func (m *MultiGitStatus) SortedRepoPaths() []string
- type PorcelainEntry
- type PorcelainStatus
- type RepoStatus
- type ScanProgress
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RepoInclusionReasons ¶ added in v1.1.0
func RepoInclusionReasons(rs RepoStatus) []string
RepoInclusionReasons returns human-readable lines explaining why a repository is included in the result list, using the same rules as ScanWithProgress and StatusForRepo (uncommitted work and/or a local/remote branch mismatch for the current branch).
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
// 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. A clean repo that is only behind the remote (incoming commits, nothing to push) is not a mismatch.
func (BranchStatus) LocalRemoteMismatchReasons ¶ added in v1.1.0
func (b BranchStatus) LocalRemoteMismatchReasons() []string
LocalRemoteMismatchReasons returns a short line explaining why BranchStatus.HasLocalRemoteMismatch is true, or nil when that predicate is false.
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 (*Config) AlwaysListBranch ¶ added in v1.0.0
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
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 (Excluder) FilterPorcelainStatus ¶ added in v1.0.0
func (e Excluder) FilterPorcelainStatus(st PorcelainStatus) PorcelainStatus
func (Excluder) IsExcluded ¶
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 struct {
// contains filtered or unexported fields
}
MultiGitStatus holds per-repository scan results. The zero value is usable: reads treat a nil receiver as empty; the first AddResult or Set allocates the inner map. Do not copy a non-zero MultiGitStatus (it contains a sync.Mutex).
func NewMultiGitStatus ¶ added in v1.3.1
func NewMultiGitStatus() *MultiGitStatus
NewMultiGitStatus returns an empty result set ready for concurrent AddResult calls.
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).
func (*MultiGitStatus) AddResult ¶ added in v1.3.1
func (m *MultiGitStatus) AddResult(path string, rs RepoStatus)
AddResult records a dirty or diverged repository; safe for concurrent use.
func (*MultiGitStatus) Delete ¶ added in v1.3.1
func (m *MultiGitStatus) Delete(path string)
Delete removes path from the set.
func (*MultiGitStatus) Get ¶ added in v1.3.1
func (m *MultiGitStatus) Get(path string) (RepoStatus, bool)
Get returns status for path, if present.
func (*MultiGitStatus) Len ¶ added in v1.3.1
func (m *MultiGitStatus) Len() int
Len returns the number of repositories recorded.
func (*MultiGitStatus) Set ¶ added in v1.3.1
func (m *MultiGitStatus) Set(path string, rs RepoStatus)
Set replaces status for path (typically the UI thread after a scan completes).
func (*MultiGitStatus) SortedRepoPaths ¶ added in v1.3.1
func (m *MultiGitStatus) SortedRepoPaths() []string
SortedRepoPaths returns repository paths in stable alphabetical order.
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
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.