Documentation
¶
Index ¶
- func MigrateRepository(old interface{}) (*Repository, *Workspace, error)
- type Branch
- type CleanRepository
- func (r *CleanRepository) GetBlob(hash string) (*object.Blob, error)
- func (r *CleanRepository) GetBranch(name string) (string, error)
- func (r *CleanRepository) GetCommit(hash string) (*object.Commit, error)
- func (r *CleanRepository) GetHEAD() (string, error)
- func (r *CleanRepository) GetObject(hash string) (object.Object, error)
- func (r *CleanRepository) GetTag(name string) (string, error)
- func (r *CleanRepository) GetTree(hash string) (*object.Tree, error)
- func (r *CleanRepository) ListBranches() ([]Branch, error)
- func (r *CleanRepository) ListTags() ([]Tag, error)
- func (r *CleanRepository) Log(startHash string, limit int) ([]*object.Commit, error)
- func (r *CleanRepository) ResolveRef(ref string) (string, error)
- type CleanStagingArea
- type CleanWorkspace
- func (w *CleanWorkspace) Add(path string) error
- func (w *CleanWorkspace) Checkout(branch string) error
- func (w *CleanWorkspace) GetStagingArea() *CleanStagingArea
- func (w *CleanWorkspace) ListFiles() ([]string, error)
- func (w *CleanWorkspace) ReadFile(path string) ([]byte, error)
- func (w *CleanWorkspace) Remove(path string) error
- func (w *CleanWorkspace) Reset()
- func (w *CleanWorkspace) Status() (*Status, error)
- func (w *CleanWorkspace) WriteFile(path string, content []byte) error
- type Config
- type ConfigStore
- type DiagnosticLogger
- type Event
- type EventHandler
- type EventManager
- type FileWorkingStorage
- func (f *FileWorkingStorage) Clear() error
- func (f *FileWorkingStorage) Close() error
- func (f *FileWorkingStorage) Delete(path string) error
- func (f *FileWorkingStorage) Exists(path string) bool
- func (f *FileWorkingStorage) List() ([]string, error)
- func (f *FileWorkingStorage) Read(path string) ([]byte, error)
- func (f *FileWorkingStorage) Write(path string, content []byte) error
- type GitOperations
- type MemoryConfigStore
- type MemoryObjectStore
- func (m *MemoryObjectStore) Close() error
- func (m *MemoryObjectStore) Exists(hash string) bool
- func (m *MemoryObjectStore) Get(hash string) (object.Object, error)
- func (m *MemoryObjectStore) List() ([]string, error)
- func (m *MemoryObjectStore) Put(obj object.Object) (string, error)
- func (m *MemoryObjectStore) Size() (int64, error)
- type MemoryRefStore
- func (m *MemoryRefStore) Close() error
- func (m *MemoryRefStore) DeleteRef(name string) error
- func (m *MemoryRefStore) GetHEAD() (string, error)
- func (m *MemoryRefStore) GetRef(name string) (string, error)
- func (m *MemoryRefStore) ListRefs() (map[string]string, error)
- func (m *MemoryRefStore) SetHEAD(ref string) error
- func (m *MemoryRefStore) UpdateRef(name, hash string) error
- type MemoryWorkingStorage
- func (m *MemoryWorkingStorage) Clear() error
- func (m *MemoryWorkingStorage) Close() error
- func (m *MemoryWorkingStorage) Delete(path string) error
- func (m *MemoryWorkingStorage) Exists(path string) bool
- func (m *MemoryWorkingStorage) List() ([]string, error)
- func (m *MemoryWorkingStorage) Read(path string) ([]byte, error)
- func (m *MemoryWorkingStorage) Write(path string, content []byte) error
- type ObjectStore
- type ObjectStoreAdapter
- func (a *ObjectStoreAdapter) Close() error
- func (a *ObjectStoreAdapter) Exists(hash string) bool
- func (a *ObjectStoreAdapter) Get(hash string) (object.Object, error)
- func (a *ObjectStoreAdapter) List() ([]string, error)
- func (a *ObjectStoreAdapter) Put(obj object.Object) (string, error)
- func (a *ObjectStoreAdapter) Size() (int64, error)
- type Operations
- func (ops *Operations) Add(paths ...string) error
- func (ops *Operations) Branch(name string) error
- func (ops *Operations) Checkout(branch string) error
- func (ops *Operations) Commit(message string) (string, error)
- func (ops *Operations) DeleteBranch(name string) error
- func (ops *Operations) Init() error
- func (ops *Operations) Log(limit int) ([]*object.Commit, error)
- func (ops *Operations) Merge(branch string, message string) (string, error)
- func (ops *Operations) Status() (*Status, error)
- func (ops *Operations) Tag(name string) error
- type RefStore
- type RefStoreAdapter
- func (a *RefStoreAdapter) Close() error
- func (a *RefStoreAdapter) DeleteRef(name string) error
- func (a *RefStoreAdapter) GetHEAD() (string, error)
- func (a *RefStoreAdapter) GetRef(name string) (string, error)
- func (a *RefStoreAdapter) ListRefs() (map[string]string, error)
- func (a *RefStoreAdapter) SetHEAD(ref string) error
- func (a *RefStoreAdapter) UpdateRef(name, hash string) error
- type Repository
- type StagedEntry
- type StagingArea
- type Stash
- type StashManager
- func (sm *StashManager) Apply(id string) error
- func (sm *StashManager) Create(message string, includeUntracked bool) (*Stash, error)
- func (sm *StashManager) Drop(id string) error
- func (sm *StashManager) Get(id string) (*Stash, error)
- func (sm *StashManager) List() []*Stash
- func (sm *StashManager) Pop(id string) error
- type Status
- type Tag
- type Webhook
- type WebhookManager
- func (wm *WebhookManager) Get(id string) (*Webhook, error)
- func (wm *WebhookManager) List() []*Webhook
- func (wm *WebhookManager) Register(url string, events []string, secret string) (*Webhook, error)
- func (wm *WebhookManager) Trigger(event string, repoName string, data interface{})
- func (wm *WebhookManager) Unregister(id string) error
- type WebhookPayload
- type WorkingStorage
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateRepository ¶
func MigrateRepository(old interface{}) (*Repository, *Workspace, error)
MigrateRepository shows how to migrate from old Repository to new architecture This is a temporary helper during refactoring
Types ¶
type CleanRepository ¶
type CleanRepository struct {
// contains filtered or unexported fields
}
CleanRepository represents the core immutable Git repository It only handles objects and references - no mutable state, no config, no webhooks
func Clone ¶
func Clone(sourceRepo *CleanRepository, targetObjects ObjectStore, targetRefs RefStore) (*CleanRepository, error)
Clone clones a repository (simplified version)
func NewCleanRepository ¶
func NewCleanRepository(objects ObjectStore, refs RefStore) *CleanRepository
NewCleanRepository creates a new clean repository
func (*CleanRepository) GetBlob ¶
func (r *CleanRepository) GetBlob(hash string) (*object.Blob, error)
GetBlob retrieves a blob by hash
func (*CleanRepository) GetBranch ¶
func (r *CleanRepository) GetBranch(name string) (string, error)
GetBranch retrieves a specific branch
func (*CleanRepository) GetCommit ¶
func (r *CleanRepository) GetCommit(hash string) (*object.Commit, error)
GetCommit retrieves a commit by hash
func (*CleanRepository) GetHEAD ¶
func (r *CleanRepository) GetHEAD() (string, error)
GetHEAD returns what HEAD points to
func (*CleanRepository) GetObject ¶
func (r *CleanRepository) GetObject(hash string) (object.Object, error)
GetObject retrieves any Git object by hash
func (*CleanRepository) GetTag ¶
func (r *CleanRepository) GetTag(name string) (string, error)
GetTag retrieves a specific tag
func (*CleanRepository) GetTree ¶
func (r *CleanRepository) GetTree(hash string) (*object.Tree, error)
GetTree retrieves a tree by hash
func (*CleanRepository) ListBranches ¶
func (r *CleanRepository) ListBranches() ([]Branch, error)
ListBranches returns all branches
func (*CleanRepository) ListTags ¶
func (r *CleanRepository) ListTags() ([]Tag, error)
ListTags returns all tags
func (*CleanRepository) ResolveRef ¶
func (r *CleanRepository) ResolveRef(ref string) (string, error)
ResolveRef resolves a reference to a commit hash
type CleanStagingArea ¶
type CleanStagingArea struct {
// contains filtered or unexported fields
}
CleanStagingArea represents the Git index/staging area
func NewCleanStagingArea ¶
func NewCleanStagingArea() *CleanStagingArea
NewCleanStagingArea creates a new staging area
type CleanWorkspace ¶
type CleanWorkspace struct {
// contains filtered or unexported fields
}
CleanWorkspace manages the mutable working directory state Separated from repository to maintain clean architecture
func NewCleanWorkspace ¶
func NewCleanWorkspace(repo *CleanRepository, working WorkingStorage) *CleanWorkspace
NewCleanWorkspace creates a new workspace
func (*CleanWorkspace) Checkout ¶
func (w *CleanWorkspace) Checkout(branch string) error
Checkout switches branches and updates working directory
func (*CleanWorkspace) GetStagingArea ¶
func (w *CleanWorkspace) GetStagingArea() *CleanStagingArea
GetStagingArea returns the current staging area
func (*CleanWorkspace) ListFiles ¶
func (w *CleanWorkspace) ListFiles() ([]string, error)
ListFiles returns all files in working directory
func (*CleanWorkspace) ReadFile ¶
func (w *CleanWorkspace) ReadFile(path string) ([]byte, error)
ReadFile reads a file from working directory
func (*CleanWorkspace) Remove ¶
func (w *CleanWorkspace) Remove(path string) error
Remove stages a file removal
func (*CleanWorkspace) Status ¶
func (w *CleanWorkspace) Status() (*Status, error)
Status returns the current workspace status
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config manages repository configuration
type ConfigStore ¶
type ConfigStore interface {
// Get retrieves a config value
Get(key string) (string, error)
// Set stores a config value
Set(key, value string) error
// Delete removes a config value
Delete(key string) error
// List returns all config keys
List() (map[string]string, error)
// Close releases any resources
io.Closer
}
ConfigStore defines the interface for configuration storage
type DiagnosticLogger ¶
type DiagnosticLogger struct {
// contains filtered or unexported fields
}
DiagnosticLogger provides detailed logging for debugging
func NewDiagnosticLogger ¶
func NewDiagnosticLogger(prefix string) *DiagnosticLogger
NewDiagnosticLogger creates a diagnostic logger
func (*DiagnosticLogger) Log ¶
func (d *DiagnosticLogger) Log(format string, args ...interface{})
Log logs a diagnostic message
func (*DiagnosticLogger) LogData ¶
func (d *DiagnosticLogger) LogData(label string, data interface{})
LogData logs data with a label
func (*DiagnosticLogger) LogError ¶
func (d *DiagnosticLogger) LogError(operation string, err error)
LogError logs an error
type EventHandler ¶
EventHandler handles repository events
type EventManager ¶
type EventManager struct {
// contains filtered or unexported fields
}
EventManager manages repository events and webhooks
func NewEventManager ¶
func NewEventManager() *EventManager
NewEventManager creates a new event manager
func (*EventManager) Publish ¶
func (em *EventManager) Publish(event Event)
Publish sends an event to all handlers
func (*EventManager) Subscribe ¶
func (em *EventManager) Subscribe(handler EventHandler)
Subscribe adds an event handler
type FileWorkingStorage ¶
type FileWorkingStorage struct {
// contains filtered or unexported fields
}
FileWorkingStorage is a file-based implementation of WorkingStorage
func NewFileWorkingStorage ¶
func NewFileWorkingStorage(root string) *FileWorkingStorage
func (*FileWorkingStorage) Clear ¶
func (f *FileWorkingStorage) Clear() error
func (*FileWorkingStorage) Close ¶
func (f *FileWorkingStorage) Close() error
func (*FileWorkingStorage) Delete ¶
func (f *FileWorkingStorage) Delete(path string) error
func (*FileWorkingStorage) Exists ¶
func (f *FileWorkingStorage) Exists(path string) bool
func (*FileWorkingStorage) List ¶
func (f *FileWorkingStorage) List() ([]string, error)
type GitOperations ¶
type GitOperations struct {
// contains filtered or unexported fields
}
GitOperations provides high-level Git operations using the clean architecture
func NewGitOperations ¶
func NewGitOperations(repo *Repository, workspace *Workspace, config *Config) *GitOperations
NewGitOperations creates a new Git operations handler
func (*GitOperations) Add ¶
func (g *GitOperations) Add(path string) error
Add stages a file (example of how operations would work)
type MemoryConfigStore ¶
type MemoryConfigStore struct {
// contains filtered or unexported fields
}
MemoryConfigStore is an in-memory config store
func NewMemoryConfigStore ¶
func NewMemoryConfigStore() *MemoryConfigStore
func (*MemoryConfigStore) Close ¶
func (m *MemoryConfigStore) Close() error
func (*MemoryConfigStore) Delete ¶
func (m *MemoryConfigStore) Delete(key string) error
func (*MemoryConfigStore) Set ¶
func (m *MemoryConfigStore) Set(key, value string) error
type MemoryObjectStore ¶
type MemoryObjectStore struct {
// contains filtered or unexported fields
}
MemoryObjectStore is a simple in-memory implementation of ObjectStore
func NewMemoryObjectStore ¶
func NewMemoryObjectStore() *MemoryObjectStore
func (*MemoryObjectStore) Close ¶
func (m *MemoryObjectStore) Close() error
func (*MemoryObjectStore) Exists ¶
func (m *MemoryObjectStore) Exists(hash string) bool
func (*MemoryObjectStore) List ¶
func (m *MemoryObjectStore) List() ([]string, error)
func (*MemoryObjectStore) Size ¶
func (m *MemoryObjectStore) Size() (int64, error)
type MemoryRefStore ¶
type MemoryRefStore struct {
// contains filtered or unexported fields
}
MemoryRefStore is a simple in-memory implementation of RefStore
func NewMemoryRefStore ¶
func NewMemoryRefStore() *MemoryRefStore
func (*MemoryRefStore) Close ¶
func (m *MemoryRefStore) Close() error
func (*MemoryRefStore) DeleteRef ¶
func (m *MemoryRefStore) DeleteRef(name string) error
func (*MemoryRefStore) GetHEAD ¶
func (m *MemoryRefStore) GetHEAD() (string, error)
func (*MemoryRefStore) SetHEAD ¶
func (m *MemoryRefStore) SetHEAD(ref string) error
func (*MemoryRefStore) UpdateRef ¶
func (m *MemoryRefStore) UpdateRef(name, hash string) error
type MemoryWorkingStorage ¶
type MemoryWorkingStorage struct {
// contains filtered or unexported fields
}
MemoryWorkingStorage is an in-memory implementation of WorkingStorage
func NewMemoryWorkingStorage ¶
func NewMemoryWorkingStorage() *MemoryWorkingStorage
func (*MemoryWorkingStorage) Clear ¶
func (m *MemoryWorkingStorage) Clear() error
func (*MemoryWorkingStorage) Close ¶
func (m *MemoryWorkingStorage) Close() error
func (*MemoryWorkingStorage) Delete ¶
func (m *MemoryWorkingStorage) Delete(path string) error
func (*MemoryWorkingStorage) Exists ¶
func (m *MemoryWorkingStorage) Exists(path string) bool
func (*MemoryWorkingStorage) List ¶
func (m *MemoryWorkingStorage) List() ([]string, error)
type ObjectStore ¶
type ObjectStore interface {
// Get retrieves an object by its hash
Get(hash string) (object.Object, error)
// Put stores an object and returns its hash
Put(obj object.Object) (string, error)
// Exists checks if an object exists
Exists(hash string) bool
// List returns all object hashes
List() ([]string, error)
// Size returns the total size of stored objects
Size() (int64, error)
// Close releases any resources
io.Closer
}
ObjectStore defines the interface for storing immutable Git objects
func AdaptOldStore ¶
func AdaptOldStore(oldStore *storage.Store) ObjectStore
Example of how to adapt old store
type ObjectStoreAdapter ¶
ObjectStoreAdapter adapts existing storage.Store to ObjectStore interface
func (*ObjectStoreAdapter) Close ¶
func (a *ObjectStoreAdapter) Close() error
func (*ObjectStoreAdapter) Exists ¶
func (a *ObjectStoreAdapter) Exists(hash string) bool
func (*ObjectStoreAdapter) Get ¶
func (a *ObjectStoreAdapter) Get(hash string) (object.Object, error)
func (*ObjectStoreAdapter) List ¶
func (a *ObjectStoreAdapter) List() ([]string, error)
func (*ObjectStoreAdapter) Put ¶
func (a *ObjectStoreAdapter) Put(obj object.Object) (string, error)
func (*ObjectStoreAdapter) Size ¶
func (a *ObjectStoreAdapter) Size() (int64, error)
type Operations ¶
type Operations struct {
// contains filtered or unexported fields
}
Operations provides high-level Git operations using clean architecture
func NewOperations ¶
func NewOperations(repo *CleanRepository, workspace *CleanWorkspace, config *Config) *Operations
NewOperations creates a new operations handler
func (*Operations) Branch ¶
func (ops *Operations) Branch(name string) error
Branch creates a new branch
func (*Operations) Checkout ¶
func (ops *Operations) Checkout(branch string) error
Checkout switches to a branch
func (*Operations) Commit ¶
func (ops *Operations) Commit(message string) (string, error)
Commit creates a new commit
func (*Operations) DeleteBranch ¶
func (ops *Operations) DeleteBranch(name string) error
DeleteBranch deletes a branch
func (*Operations) Log ¶
func (ops *Operations) Log(limit int) ([]*object.Commit, error)
Log returns commit history
func (*Operations) Merge ¶
func (ops *Operations) Merge(branch string, message string) (string, error)
Merge merges another branch into current branch
func (*Operations) Status ¶
func (ops *Operations) Status() (*Status, error)
Status returns repository status
type RefStore ¶
type RefStore interface {
// GetRef returns the hash a reference points to
GetRef(name string) (string, error)
// UpdateRef updates a reference to point to a new hash
UpdateRef(name string, hash string) error
// DeleteRef removes a reference
DeleteRef(name string) error
// ListRefs returns all references
ListRefs() (map[string]string, error)
// GetHEAD returns what HEAD points to
GetHEAD() (string, error)
// SetHEAD updates HEAD
SetHEAD(target string) error
// Close releases any resources
io.Closer
}
RefStore defines the interface for managing references
func AdaptOldRefManager ¶
func AdaptOldRefManager(oldRefManager *refs.RefManager) RefStore
Example of how to use adapters during migration
type RefStoreAdapter ¶
type RefStoreAdapter struct {
RefManager *refs.RefManager
Store refs.RefStore
}
RefStoreAdapter adapts refs.RefManager to RefStore interface
func (*RefStoreAdapter) Close ¶
func (a *RefStoreAdapter) Close() error
func (*RefStoreAdapter) DeleteRef ¶
func (a *RefStoreAdapter) DeleteRef(name string) error
func (*RefStoreAdapter) GetHEAD ¶
func (a *RefStoreAdapter) GetHEAD() (string, error)
func (*RefStoreAdapter) SetHEAD ¶
func (a *RefStoreAdapter) SetHEAD(ref string) error
func (*RefStoreAdapter) UpdateRef ¶
func (a *RefStoreAdapter) UpdateRef(name, hash string) error
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository represents the core immutable Git repository It only handles objects and references, no mutable state
func NewRepository ¶
func NewRepository(objects ObjectStore, refs RefStore) *Repository
NewRepository creates a new repository with the given stores
func (*Repository) Objects ¶
func (r *Repository) Objects() ObjectStore
Objects returns the object store
type StagedEntry ¶
StagedEntry represents a file in the staging area
type StagingArea ¶
type StagingArea struct {
// contains filtered or unexported fields
}
StagingArea represents the Git staging area (index)
func NewStagingArea ¶
func NewStagingArea() *StagingArea
NewStagingArea creates a new empty staging area
type Stash ¶
type Stash struct {
ID string
Message string
Author object.Author
TreeHash string // Hash of the stashed tree
ParentCommit string // Commit hash when stash was created
Timestamp time.Time
Changes map[string][]byte // Unstaged changes
Index map[string]string // Staged changes (path -> hash)
Untracked map[string][]byte // Untracked files
}
Stash represents a saved workspace state
type StashManager ¶
type StashManager struct {
// contains filtered or unexported fields
}
StashManager manages repository stashes
func NewStashManager ¶
func NewStashManager(repo *CleanRepository, workspace *CleanWorkspace) *StashManager
NewStashManager creates a new stash manager
func (*StashManager) Apply ¶
func (sm *StashManager) Apply(id string) error
Apply applies a stash to the current workspace
func (*StashManager) Create ¶
func (sm *StashManager) Create(message string, includeUntracked bool) (*Stash, error)
Create creates a new stash
func (*StashManager) Get ¶
func (sm *StashManager) Get(id string) (*Stash, error)
Get returns a specific stash
func (*StashManager) Pop ¶
func (sm *StashManager) Pop(id string) error
Pop applies and drops a stash
type Webhook ¶
type Webhook struct {
ID string `json:"id"`
URL string `json:"url"`
Events []string `json:"events"`
Secret string `json:"secret"`
ContentType string `json:"content_type"`
}
Webhook represents a repository webhook
type WebhookManager ¶
type WebhookManager struct {
// contains filtered or unexported fields
}
WebhookManager manages repository webhooks
func NewWebhookManager ¶
func NewWebhookManager() *WebhookManager
NewWebhookManager creates a new webhook manager
func (*WebhookManager) Get ¶
func (wm *WebhookManager) Get(id string) (*Webhook, error)
Get returns a specific webhook
func (*WebhookManager) Trigger ¶
func (wm *WebhookManager) Trigger(event string, repoName string, data interface{})
Trigger sends an event to all registered webhooks
func (*WebhookManager) Unregister ¶
func (wm *WebhookManager) Unregister(id string) error
Unregister removes a webhook
type WebhookPayload ¶
type WebhookPayload struct {
Event string `json:"event"`
Repository string `json:"repository"`
Timestamp time.Time `json:"timestamp"`
Data interface{} `json:"data"`
}
WebhookPayload represents the payload sent to webhooks
type WorkingStorage ¶
type WorkingStorage interface {
// Read reads a file from working directory
Read(path string) ([]byte, error)
// Write writes a file to working directory
Write(path string, data []byte) error
// Delete removes a file from working directory
Delete(path string) error
// List returns all files in working directory
List() ([]string, error)
// Clear removes all files
Clear() error
// Exists checks if a file exists
Exists(path string) bool
// Close releases any resources
io.Closer
}
WorkingStorage defines the interface for working directory storage
type Workspace ¶
type Workspace struct {
// contains filtered or unexported fields
}
Workspace represents the mutable working directory state
func NewWorkspace ¶
func NewWorkspace(repo *Repository, working WorkingStorage) *Workspace
NewWorkspace creates a new workspace