Documentation
¶
Overview ¶
Package repository provides functionality for cloning and managing Git repositories. It supports GitHub repositories with authentication via CLI or personal tokens, handles repository analysis, and manages temporary storage with automatic cleanup.
Index ¶
- type GitHubConfig
- type GitHubManager
- type MockGitHubManager
- func (m *MockGitHubManager) CheckAuthentication(ctx context.Context) error
- func (m *MockGitHubManager) CleanupRepository(localPath string) error
- func (m *MockGitHubManager) CloneRepository(ctx context.Context, repoURL string) (*RepositoryInfo, error)
- func (m *MockGitHubManager) GetCallLog() []string
- func (m *MockGitHubManager) GetRepositoryInfo(localPath string) (*RepositoryInfo, error)
- func (m *MockGitHubManager) ParseRepositoryURL(url string) (owner, repo string, err error)
- func (m *MockGitHubManager) SetAuthError(err error)
- func (m *MockGitHubManager) SetCloneError(err error)
- func (m *MockGitHubManager) SetMockRepository(url string, info *RepositoryInfo)
- type RepositoryInfo
- type RepositoryManager
- func (rm *RepositoryManager) CheckAuthentication(ctx context.Context) error
- func (rm *RepositoryManager) CleanupAll() error
- func (rm *RepositoryManager) CloneAndTrack(ctx context.Context, repoURL string) (*RepositoryInfo, error)
- func (rm *RepositoryManager) GetActiveRepositories() map[string]*RepositoryInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitHubConfig ¶
type GitHubConfig struct {
// Authentication
UseGitHubCLI bool // Use GitHub CLI (gh) for authenticated operations
PersonalToken string // GitHub personal access token (alternative to CLI)
// Clone options
ShallowClone bool // Use shallow clone (--depth 1)
CloneTimeout time.Duration // Timeout for clone operations
TempDir string // Base directory for temporary clones
// Limits
MaxRepositorySize int64 // Maximum repository size in bytes (0 = no limit)
MaxFileCount int // Maximum number of files (0 = no limit)
// Cleanup
AutoCleanup bool // Automatically cleanup on errors
}
GitHubConfig configures GitHub repository operations
func DefaultGitHubConfig ¶
func DefaultGitHubConfig() GitHubConfig
DefaultGitHubConfig returns sensible defaults
type GitHubManager ¶
type GitHubManager interface {
// Authentication
CheckAuthentication(ctx context.Context) error
// Repository operations
CloneRepository(ctx context.Context, repoURL string) (*RepositoryInfo, error)
GetRepositoryInfo(localPath string) (*RepositoryInfo, error)
CleanupRepository(localPath string) error
// URL parsing
ParseRepositoryURL(url string) (owner, repo string, err error)
}
GitHubManager handles GitHub repository operations
func NewGitHubManager ¶
func NewGitHubManager(config GitHubConfig) GitHubManager
NewGitHubManager creates a new GitHub repository manager
type MockGitHubManager ¶
type MockGitHubManager struct {
AuthError error
CloneError error
MockRepositories map[string]*RepositoryInfo
CallLog []string
}
MockGitHubManager provides a mock implementation for testing
func NewMockGitHubManager ¶
func NewMockGitHubManager() *MockGitHubManager
NewMockGitHubManager creates a new mock GitHub manager
func (*MockGitHubManager) CheckAuthentication ¶
func (m *MockGitHubManager) CheckAuthentication(ctx context.Context) error
CheckAuthentication simulates authentication check
func (*MockGitHubManager) CleanupRepository ¶
func (m *MockGitHubManager) CleanupRepository(localPath string) error
CleanupRepository removes the mock repository
func (*MockGitHubManager) CloneRepository ¶
func (m *MockGitHubManager) CloneRepository(ctx context.Context, repoURL string) (*RepositoryInfo, error)
CloneRepository simulates repository cloning
func (*MockGitHubManager) GetCallLog ¶
func (m *MockGitHubManager) GetCallLog() []string
GetCallLog returns the log of method calls
func (*MockGitHubManager) GetRepositoryInfo ¶
func (m *MockGitHubManager) GetRepositoryInfo(localPath string) (*RepositoryInfo, error)
GetRepositoryInfo returns mock repository information
func (*MockGitHubManager) ParseRepositoryURL ¶
func (m *MockGitHubManager) ParseRepositoryURL(url string) (owner, repo string, err error)
ParseRepositoryURL parses repository URLs (same as real implementation)
func (*MockGitHubManager) SetAuthError ¶
func (m *MockGitHubManager) SetAuthError(err error)
SetAuthError configures authentication to fail
func (*MockGitHubManager) SetCloneError ¶
func (m *MockGitHubManager) SetCloneError(err error)
SetCloneError configures cloning to fail
func (*MockGitHubManager) SetMockRepository ¶
func (m *MockGitHubManager) SetMockRepository(url string, info *RepositoryInfo)
SetMockRepository configures a mock repository response
type RepositoryInfo ¶
type RepositoryInfo struct {
URL string `json:"url"`
Owner string `json:"owner"`
Name string `json:"name"`
LocalPath string `json:"local_path"`
Size int64 `json:"size"` // Total size in bytes
FileCount int `json:"file_count"` // Number of files (excluding .git)
ClonedAt time.Time `json:"cloned_at"`
IsShallow bool `json:"is_shallow"` // Whether it's a shallow clone
}
RepositoryInfo contains information about a cloned repository
type RepositoryManager ¶
type RepositoryManager struct {
// contains filtered or unexported fields
}
RepositoryManager provides high-level repository management
func NewRepositoryManager ¶
func NewRepositoryManager(githubConfig GitHubConfig) *RepositoryManager
NewRepositoryManager creates a new repository manager
func (*RepositoryManager) CheckAuthentication ¶
func (rm *RepositoryManager) CheckAuthentication(ctx context.Context) error
CheckAuthentication checks GitHub authentication
func (*RepositoryManager) CleanupAll ¶
func (rm *RepositoryManager) CleanupAll() error
CleanupAll cleans up all tracked repositories
func (*RepositoryManager) CloneAndTrack ¶
func (rm *RepositoryManager) CloneAndTrack(ctx context.Context, repoURL string) (*RepositoryInfo, error)
CloneAndTrack clones a repository and tracks it for later cleanup
func (*RepositoryManager) GetActiveRepositories ¶
func (rm *RepositoryManager) GetActiveRepositories() map[string]*RepositoryInfo
GetActiveRepositories returns information about all active repositories