Documentation
¶
Overview ¶
Package update provides repository update orchestration and output formatting.
Index ¶
- Constants
- func DetermineRequiredRepositories(caproniCfg *v2.CaproniConfig) *orderedmap.OrderedMap[string, bool]
- func FormatSuggestions(results []*UpdateResult) string
- func FormatSummary(results []*UpdateResult) string
- func FormatTable(results []*UpdateResult, quiet bool) (string, error)
- type RepoFilterFunc
- type UpdateOptions
- type UpdateResult
- type UpdateStatus
- type UpdateStrategy
- type Updater
Constants ¶
const ( // IconUpdated is the icon for successfully updated repositories. IconUpdated = "✓" // IconDiverged is the icon for diverged branches. IconDiverged = "⚠" // IconDirty is the icon for repositories with uncommitted changes. IconDirty = "⚠" // IconDetached is the icon for detached HEAD state. IconDetached = "⚠" // IconWarning is the icon for warning conditions. IconWarning = "⚠" // IconFailed is the icon for failed operations. IconFailed = "✗" // IconSkipped is the icon for skipped repositories. IconSkipped = "○" )
Variables ¶
This section is empty.
Functions ¶
func DetermineRequiredRepositories ¶
func DetermineRequiredRepositories(caproniCfg *v2.CaproniConfig) *orderedmap.OrderedMap[string, bool]
DetermineRequiredRepositories returns the set of repository names that are required based on edit_mode deployers and reloaders in the configuration. The returned OrderedMap preserves the order in which repositories appear in the config.
func FormatSuggestions ¶
func FormatSuggestions(results []*UpdateResult) string
FormatSuggestions generates actionable suggestions for repositories needing attention.
func FormatSummary ¶
func FormatSummary(results []*UpdateResult) string
FormatSummary generates summary counts with pterm styling.
func FormatTable ¶
func FormatTable(results []*UpdateResult, quiet bool) (string, error)
FormatTable formats results as a styled table using pterm.
Types ¶
type RepoFilterFunc ¶
RepoFilterFunc is a predicate function that determines whether a repository should be processed. It receives the repository name and returns true if the repo should be processed, false to skip.
type UpdateOptions ¶
type UpdateOptions struct {
Strategy UpdateStrategy
Stash bool
Filter RepoFilterFunc
Quiet bool
}
UpdateOptions contains options for the update operation.
type UpdateResult ¶
type UpdateResult struct {
RepoName string
Status UpdateStatus
Branch string
DefaultBranch string
CommitsBehind int
CommitsAhead int
TrackingBranch string
Notes string
Error error
}
UpdateResult represents the result of updating a single repository.
type UpdateStatus ¶
type UpdateStatus int
UpdateStatus represents the status of a repository update operation.
const ( // StatusUpdated indicates the repository was successfully updated. StatusUpdated UpdateStatus = iota // StatusDiverged indicates the local branch has diverged from remote. StatusDiverged // StatusDirty indicates uncommitted changes prevent update. StatusDirty // StatusDetached indicates HEAD is detached (not on any branch). StatusDetached // StatusWarning indicates a warning condition (no tracking branch, remote mismatch, etc.). StatusWarning // StatusFailed indicates the update operation failed. StatusFailed // StatusSkipped indicates the repository was skipped (not cloned, filtered out, etc.). StatusSkipped )
func (UpdateStatus) String ¶
func (s UpdateStatus) String() string
String returns a human-readable string representation of the status.
type UpdateStrategy ¶
type UpdateStrategy int
UpdateStrategy defines the strategy for repository updates.
const ( // StrategyFullUpdate performs complete operations: clone missing edit_mode repos and update existing repos. // This is the default strategy for 'caproni update'. StrategyFullUpdate UpdateStrategy = iota // StrategyMinimalRequired performs minimal actions: clone missing repos only, skip all updates. // This is used by 'caproni up' to ensure repos exist before starting the cluster. StrategyMinimalRequired // StrategyVerifyOnly checks repository states without making any changes (dry-run mode). StrategyVerifyOnly )
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater orchestrates repository updates.
func NewUpdater ¶
func NewUpdater(backend git.Backend, opts UpdateOptions) *Updater
NewUpdater creates a new Updater with the given backend and options.
func (*Updater) UpdateRepositories ¶
func (u *Updater) UpdateRepositories(ctx context.Context, exec executor.CommandRunner, caproniCfg *v2.CaproniConfig) ([]*UpdateResult, bool)
UpdateRepositories updates multiple repositories based on configuration. Returns results for all repositories and a success flag. The success flag is false if any repository has StatusFailed.