Documentation
¶
Overview ¶
Package clone provides functionality for cloning and managing Git repositories in bulk.
Index ¶
- type Config
- type Manager
- func (m *Manager) CloneAll(ctx context.Context) error
- func (m *Manager) CloneRepositories(ctx context.Context, repos []*provider.Repository, outputDir string, ...) ([]*Result, error)
- func (m *Manager) CloneRepository(ctx context.Context, repo *provider.Repository) error
- func (m *Manager) Close() error
- func (m *Manager) GetResults() map[string]*Result
- type OperationStats
- type Result
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
WorkerConfig *worker.Config
OutputDir string
UseSSH bool
UseGHRepoClone bool
Mirror bool
Bare bool
Depth int
Verbose bool
DryRun bool
ContinueOnFail bool
// Enhanced error handling options
SkipExisting bool // Skip existing repositories instead of failing
ValidateClone bool // Validate that clone was successful
CleanupOnFailure bool // Remove failed clone directories
CloneArchived bool // Whether to clone archived/read-only repositories
MaxConcurrentOps int // Maximum concurrent clone operations per worker
// Timeout configuration
CloneTimeout time.Duration // Individual git clone operation timeout
NetworkTimeout time.Duration // Network operation timeout for git commands
// SSH configuration
SSHConfig *sshauth.Config
// Credential management
DisableCredentialHelpers bool // Disable git credential helpers to prevent password prompts
PreCommitInstallHooks bool // Install pre-commit hooks with 'pre-commit install' after clone
}
Config holds configuration for clone operations
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a sensible default configuration
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles bulk cloning operations
func NewManager ¶
NewManager creates a new clone manager
func (*Manager) CloneRepositories ¶
func (m *Manager) CloneRepositories(ctx context.Context, repos []*provider.Repository, outputDir string, dryRun bool, useSSH bool) ([]*Result, error)
CloneRepositories clones a specific list of repositories
func (*Manager) CloneRepository ¶
CloneRepository clones a single repository
func (*Manager) GetResults ¶
GetResults returns all clone results
type OperationStats ¶
type OperationStats struct {
TotalRepositories int
Successful int
Failed int
Skipped int
StartTime time.Time
EndTime time.Time
Errors []error
// contains filtered or unexported fields
}
OperationStats tracks clone operation statistics
func (*OperationStats) Duration ¶
func (s *OperationStats) Duration() time.Duration
Duration returns the total duration of the operations
func (*OperationStats) IncFailed ¶
func (s *OperationStats) IncFailed(err error)
IncFailed increments the failed operation counter and adds the error
func (*OperationStats) IncSkipped ¶
func (s *OperationStats) IncSkipped()
IncSkipped increments the skipped operation counter
func (*OperationStats) IncSuccessful ¶
func (s *OperationStats) IncSuccessful()
IncSuccessful increments the successful operation counter
func (*OperationStats) LogSummary ¶
func (s *OperationStats) LogSummary()
LogSummary logs a summary of the operation statistics
func (*OperationStats) SetEndTime ¶
func (s *OperationStats) SetEndTime(t time.Time)
SetEndTime sets the end time for the operations
type Result ¶
type Result struct {
Repository *provider.Repository
LocalPath string
Error error
Duration time.Duration
JobID string
Status Status
RetryCount int
// Pre-commit installation reporting
PreCommitInstalled bool // true if pre-commit install succeeded
PreCommitSkipped bool // true if skipped due to missing .pre-commit-config.yaml
PreCommitError string // non-empty if pre-commit install errored
}
Result represents the result of a clone operation
type Status ¶
type Status string
Status represents the status of a clone operation
const ( // StatusPending indicates the operation is waiting to start StatusPending Status = "pending" // StatusRunning indicates the operation is currently running StatusRunning Status = "running" // StatusSuccess indicates the operation completed successfully StatusSuccess Status = "success" // StatusFailed indicates the operation failed StatusFailed Status = "failed" // StatusSkipped indicates the operation was skipped StatusSkipped Status = "skipped" // StatusExists indicates the target already exists StatusExists Status = "exists" // StatusValidated indicates the operation was validated StatusValidated Status = "validated" )