sync

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package sync provides repository synchronization functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitRetryConfig added in v1.0.19

type GitRetryConfig struct {
	// MaxAttempts is the total number of attempts (initial + retries)
	MaxAttempts int
	// InitialDelay is the delay before the first retry
	InitialDelay time.Duration
	// MaxDelay is the maximum delay between retries
	MaxDelay time.Duration
	// Multiplier is the exponential backoff multiplier
	Multiplier float64
}

GitRetryConfig configures retry behavior for git operations

func DefaultGitRetryConfig added in v1.0.19

func DefaultGitRetryConfig() *GitRetryConfig

DefaultGitRetryConfig returns sensible defaults for retrying git operations. Designed for transient failures like file locking (e.g., Dropbox on Windows).

type Options

type Options struct {
	// Target directory for synced repositories
	Target string

	// Include patterns for repository names (glob-style)
	Include []string

	// Exclude patterns for repository names (glob-style)
	Exclude []string

	// IncludePrivate includes private repositories
	IncludePrivate bool

	// DryRun simulates the sync without making changes
	DryRun bool

	// Verbose enables verbose output
	Verbose bool

	// OnProgress is called to report sync progress (optional)
	OnProgress ProgressCallback

	// Concurrency sets the number of parallel sync operations (default: 1)
	Concurrency int

	// SkipArchiveDetection skips the detectArchived() call which walks the entire
	// target directory. This is useful when syncing single repos (e.g., TUI worker)
	// where archive detection should be done once at the end, not per-repo.
	SkipArchiveDetection bool
}

Options configures the sync operation

type ProgressCallback

type ProgressCallback func(repoName string, status ProgressStatus, message string)

ProgressCallback is called to report sync progress repoName is the full repository name (owner/repo) status is the current status message provides additional context (e.g., error message)

type ProgressStatus

type ProgressStatus int

ProgressStatus represents the status of a sync operation

const (
	// ProgressPending indicates the repo is queued for sync
	ProgressPending ProgressStatus = iota
	// ProgressInProgress indicates the repo is currently being synced
	ProgressInProgress
	// ProgressCloned indicates the repo was cloned
	ProgressCloned
	// ProgressUpdated indicates the repo was updated
	ProgressUpdated
	// ProgressUpToDate indicates the repo is already up-to-date (fast check)
	ProgressUpToDate
	// ProgressSkipped indicates the repo was skipped
	ProgressSkipped
	// ProgressFailed indicates the repo sync failed
	ProgressFailed
)

type Result

type Result struct {
	// Cloned repositories
	Cloned []string

	// Updated repositories (pulled)
	Updated []string

	// UpToDate repositories (already current, no pull needed)
	UpToDate []string

	// Skipped repositories (filtered out)
	Skipped []string

	// Failed repositories with errors
	Failed map[string]error

	// Archived repositories (exist locally but not on remote - preserved for backup)
	Archived []string
}

Result represents the result of a sync operation

func NewResult

func NewResult() *Result

NewResult creates a new sync result

type Syncer

type Syncer struct {
	// contains filtered or unexported fields
}

Syncer handles repository synchronization

func New

func New(ghClient github.Client, g *git.Git, opts *Options) *Syncer

New creates a new Syncer

func (*Syncer) SyncOrgRepos

func (s *Syncer) SyncOrgRepos(ctx context.Context, org string) (*Result, error)

SyncOrgRepos syncs all repositories for an organization

func (*Syncer) SyncRepo

func (s *Syncer) SyncRepo(ctx context.Context, owner, repo string) (*Result, error)

SyncRepo syncs a single repository

func (*Syncer) SyncRepoWithData

func (s *Syncer) SyncRepoWithData(ctx context.Context, repo *gh.Repository) (*Result, error)

SyncRepoWithData syncs a single repository using pre-fetched data. This avoids redundant API calls when the repository data is already available.

func (*Syncer) SyncUserRepos

func (s *Syncer) SyncUserRepos(ctx context.Context, username string) (*Result, error)

SyncUserRepos syncs all repositories for a user

Jump to

Keyboard shortcuts

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