fleetsync

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fleetsync decides and performs the sync action for a single repo: clone or pull an active repo, or remove/keep an archived one's local clone. It has no TUI or terminal output of its own — callers (e.g. the wb sync worker pool) drive it and render results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Repo   discover.Repo
	Status Status
	// PullPlanned is true only for a dry-run existing clone. PullAttempted and
	// PullSucceeded describe the real action independently of Status, which may
	// still end as Unpushed after a successful pull. Updated is a successful
	// pull whose checked-out commit moved forward.
	PullPlanned   bool
	PullAttempted bool
	PullSucceeded bool
	Updated       bool
	Detail        gitops.RepoStatus
	// Tracking is filled in only for Diverged and NoUpstream, whose reports
	// are meaningless without the branch names and ahead/behind counts.
	Tracking gitops.TrackingState
	Err      error
}

Result is the outcome of syncing one repo.

func Sync

func Sync(repo discover.Repo, projectsRoot string, dryRun bool) Result

Sync reconciles a single repo's local clone with its GitHub state: clone if missing, pull if present and clean, skip if the working tree is dirty. For archived repos: remove the local clone if it is safe to (clean, no stash, nothing unpushed), otherwise keep it and report why. Forks and repos not owned by the authenticated user or their orgs (repo.Remote == false) are left untouched (NoOp). Repos marked with `wb repo ignore` are left untouched too (SkippedIgnored), including archived ones. In dryRun mode no mutation happens; Status still reports what would be done.

func (Result) PullSummary added in v0.55.0

func (r Result) PullSummary() string

PullSummary renders the pull action independently of the final repository status. Empty means this result did not concern an existing active clone.

type Status

type Status int

Status is the outcome fleetsync.Sync took for a single repo.

const (
	Cloned Status = iota
	Pulled
	SkippedDirty
	RemovedArchived
	KeptArchived
	AbsentArchived
	NoOp
	Failed
	// SkippedIgnored, EmptyRemote, Diverged and NoUpstream are appended last
	// deliberately: Status is rendered only through String() and never
	// persisted numerically, but appending keeps the existing values stable
	// regardless.
	SkippedIgnored
	EmptyRemote
	// Diverged: the branch and its upstream each hold commits the other
	// lacks, so no fast-forward is possible and sync must not guess a
	// reconciliation.
	Diverged
	// NoUpstream: the checked-out branch tracks nothing, so there is nowhere
	// to pull from.
	NoUpstream
	// Unpushed: the pull succeeded, but the clone holds commits that exist on
	// no remote. Nothing is wrong with the sync; the work has simply never
	// left this machine.
	Unpushed
	// ArchivedUnlandable: an archived clone holding unpushed commits. The
	// remote is read-only, so those commits can never be pushed — unlike
	// KeptArchived, this state cannot resolve itself and needs a decision.
	ArchivedUnlandable
)

func (Status) String

func (s Status) String() string

type SummaryGroup added in v0.56.0

type SummaryGroup struct {
	Label   string
	Section SummarySection
	Results []Result
}

SummaryGroup is one selectable/countable row in the final sync summary. Results are sorted by repository slug so every renderer is deterministic. A result may belong to both an action row and a final-outcome row.

func Summary added in v0.56.0

func Summary(results []Result) []SummaryGroup

Summary builds the ordered category model shared by plain output and the interactive results browser.

func SummaryGroupByLabel added in v0.56.0

func SummaryGroupByLabel(groups []SummaryGroup, label string) (SummaryGroup, bool)

SummaryGroupByLabel finds a summary row by its stable display label.

type SummarySection added in v0.56.0

type SummarySection string

SummarySection groups related rows in both the plain and interactive sync summaries. Its value is the human-readable section heading.

const (
	SummaryFinalOutcomes SummarySection = "Final outcomes"
	SummaryPullActions   SummarySection = "Pull actions"
	SummaryAttention     SummarySection = "Attention"
	SummaryErrors        SummarySection = "Failures"
)

Jump to

Keyboard shortcuts

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