Documentation
¶
Overview ¶
Package discover finds the repositories to operate on by reconciling the local ~/projects/{org}/{repo} tree with the non-archived repositories GitHub reports for the relevant orgs.
Index ¶
Constants ¶
const LocalIndexSchemaVersion = 1
Variables ¶
This section is empty.
Functions ¶
func IsArchived ¶ added in v0.60.0
IsArchived confirms, live against GitHub, whether the repository named by slug ("owner/repository") is archived right now. It is deliberately a single per-repository query rather than a reuse of a fleet-wide listing (ListRemote, or a caller's own cached Repo.Archived): a bulk listing can be stale by the time a destructive decision is made from it, can silently omit a repository the caller lacks org-listing access to, and answers "was this archived when the list was built" rather than "is this archived now". A caller about to delete a local clone based on archived status must ask this exact question about this exact repository immediately before acting, and must treat any error (network, auth, rate limit, unknown repository) as "could not confirm" rather than guessing either way.
func MemberOrgs ¶
MemberOrgs returns the GitHub orgs the authenticated user belongs to. This is the authoritative source of "owners I control" — local directory names are not, since they include third-party clones.
Types ¶
type LocalIndexOptions ¶ added in v0.111.3
LocalIndexOptions configures the persisted read-only fleet index. A blank CachePath deliberately falls back to a fresh scan. Callers that can mutate a repository continue to use ScanLocal so cached discovery never grants write authority.
type LocalIndexResult ¶ added in v0.111.3
type LocalIndexResult struct {
Repositories []Repo
SourceFingerprint string
ObservedAt time.Time
CacheHit bool
Diagnostics []string
}
LocalIndexResult describes whether discovery reused a persisted observation. Diagnostics are cache-only failures: fresh discovery still succeeds when a cache is corrupt or temporarily unwritable.
func ScanLocalIndexed ¶ added in v0.111.3
func ScanLocalIndexed(projectsRoot string, options LocalIndexOptions) (LocalIndexResult, error)
ScanLocalIndexed reuses a persisted canonical-clone inventory only for a bounded time and only while the projects root and organization-directory metadata fingerprint is unchanged. Nested changes that do not update an organization directory are bounded by MaxAge. The index is discovery data, never mutation evidence.
type Repo ¶
type Repo struct {
Org string
Name string
Path string // local working-tree path; empty if not cloned locally
CloneURL string // ssh URL from GitHub; empty if only known locally
Archived bool
IsFork bool
Local bool
Remote bool
}
Repo identifies a single repository and where it lives.
func ListRemote ¶
ListRemote returns all repos for owner via gh. The archived flag is preserved so callers can report and skip archived repos explicitly.
func Reconcile ¶
Reconcile merges locally-cloned repos with remotely-listed ones, keyed by org/name. Remote metadata (archived flag, clone URL) wins where both exist. The result is sorted by slug for deterministic output.