gitdiscover

package
v1.52.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package gitdiscover finds git repositories near a directory: the enclosing repo (upward walk, same discovery rule as git itself) and immediate sub-repositories (one level down). Pure filesystem probes — no git binary, no I/O errors surfaced: every failure degrades to "no candidates" so discovery can never block pane creation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Candidates

func Candidates(ctx context.Context, dir string) []string

Candidates returns the repos to offer for dir: the enclosing repo first (if any), then one-level sub-repos, deduplicated, absolute paths.

ctx bounds a scan that is still making progress — a directory with thousands of entries, or a slow-but-live network mount — and a cancelled scan returns what it already had rather than an error, matching how every other failure in this package degrades. It deliberately does NOT protect against a hung mount: a syscall already blocked in the kernel cannot be cancelled from Go, so the first stat against a dead NFS server hangs regardless. Read this as "bounded work", not "bounded time".

func EnclosingRepo

func EnclosingRepo(dir string) (string, bool)

EnclosingRepo walks up from dir and returns the first ancestor (or dir itself) containing a .git entry. Symlinks are resolved first to match the daemon's defaultCWD discipline.

func SubRepos

func SubRepos(ctx context.Context, dir string) []string

SubRepos returns the immediate (one level down) subdirectories of dir that contain a .git entry. Returns nil on any read error.

ctx is checked between entries, so a large directory stops early when the caller gives up. It cannot interrupt a stat already blocked in the kernel — see Candidates for what that bound is and is not worth.

Types

This section is empty.

Jump to

Keyboard shortcuts

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