Documentation
¶
Index ¶
- Variables
- func IsAuthError(err error) bool
- func IsNoRemoteError(err error) bool
- func IsNotRepositoryError(err error) bool
- type GitError
- type GitRepository
- type MemoryRepository
- func (r *MemoryRepository) Add(patterns ...string) error
- func (r *MemoryRepository) Commit(message string) error
- func (r *MemoryRepository) CreateFile(filename, content string) error
- func (r *MemoryRepository) Exists() (bool, error)
- func (r *MemoryRepository) GetWorkingDirectory() string
- func (r *MemoryRepository) HasRemote() (bool, error)
- func (r *MemoryRepository) Init(branch string) error
- func (r *MemoryRepository) Push() error
- func (r *MemoryRepository) PushContext(ctx context.Context) error
- func (r *MemoryRepository) SetRemote(name, url string) error
- func (r *MemoryRepository) Status() ([]string, error)
- type Repository
- func (r *Repository) Add(patterns ...string) error
- func (r *Repository) Commit(message string) error
- func (r *Repository) Exists() (bool, error)
- func (r *Repository) GetWorkingDirectory() string
- func (r *Repository) HasRemote() (bool, error)
- func (r *Repository) Init(branch string) error
- func (r *Repository) Push() error
- func (r *Repository) PushContext(ctx context.Context) error
- func (r *Repository) SetRemote(name, url string) error
- func (r *Repository) Status() ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoRemote = errors.New("no remote origin configured") ErrAuthFailed = errors.New("authentication failed") ErrNotRepository = errors.New("not a git repository") )
Common git operation errors
Functions ¶
func IsAuthError ¶ added in v0.8.0
IsAuthError checks if an error is due to authentication failure
func IsNoRemoteError ¶ added in v0.8.0
IsNoRemoteError checks if an error is due to missing remote configuration
func IsNotRepositoryError ¶ added in v0.8.0
IsNotRepositoryError checks if an error is due to not being in a git repository
Types ¶
type GitError ¶ added in v0.8.0
type GitError struct { Op string // Operation that failed (e.g., "init", "add", "commit", "push") Path string // Path where the operation failed Err error // Underlying error }
GitError represents a git operation error with context
type GitRepository ¶ added in v0.8.0
type GitRepository interface { // Init initializes a git repository with the specified branch name Init(branch string) error // Add stages files for commit. Use "." to add all files Add(patterns ...string) error // Commit creates a commit with the given message Commit(message string) error // Push pushes commits to the remote repository Push() error // PushContext pushes commits to the remote repository with context for cancellation PushContext(ctx context.Context) error // Status returns a list of changed files Status() ([]string, error) // HasRemote checks if a remote named "origin" is configured HasRemote() (bool, error) // SetRemote sets a remote repository URL SetRemote(name, url string) error // GetWorkingDirectory returns the path to the working directory GetWorkingDirectory() string // Exists checks if a git repository exists at the working directory Exists() (bool, error) }
GitRepository defines the interface for git operations This interface allows for easy testing by providing mockable methods
func NewMemoryRepository ¶ added in v0.8.0
func NewMemoryRepository(workingDir string) GitRepository
NewMemoryRepository creates a new in-memory repository for testing
func NewRepository ¶ added in v0.8.0
func NewRepository(workingDir string) (GitRepository, error)
NewRepository creates a new Repository instance
type MemoryRepository ¶ added in v0.8.0
type MemoryRepository struct {
// contains filtered or unexported fields
}
MemoryRepository implements GitRepository using in-memory storage This is perfect for testing as it doesn't touch the filesystem
func (*MemoryRepository) Add ¶ added in v0.8.0
func (r *MemoryRepository) Add(patterns ...string) error
Add stages files for commit
func (*MemoryRepository) Commit ¶ added in v0.8.0
func (r *MemoryRepository) Commit(message string) error
Commit creates a commit with the given message
func (*MemoryRepository) CreateFile ¶ added in v0.8.0
func (r *MemoryRepository) CreateFile(filename, content string) error
CreateFile creates a file in the in-memory filesystem for testing
func (*MemoryRepository) Exists ¶ added in v0.8.0
func (r *MemoryRepository) Exists() (bool, error)
Exists checks if a git repository exists (always true for memory repos after Init)
func (*MemoryRepository) GetWorkingDirectory ¶ added in v0.8.0
func (r *MemoryRepository) GetWorkingDirectory() string
GetWorkingDirectory returns the path to the working directory
func (*MemoryRepository) HasRemote ¶ added in v0.8.0
func (r *MemoryRepository) HasRemote() (bool, error)
HasRemote checks if a remote named "origin" is configured
func (*MemoryRepository) Init ¶ added in v0.8.0
func (r *MemoryRepository) Init(branch string) error
Init initializes a git repository with the specified branch name
func (*MemoryRepository) Push ¶ added in v0.8.0
func (r *MemoryRepository) Push() error
Push pushes commits to the remote repository
func (*MemoryRepository) PushContext ¶ added in v0.8.0
func (r *MemoryRepository) PushContext(ctx context.Context) error
PushContext pushes commits to the remote repository with context
func (*MemoryRepository) SetRemote ¶ added in v0.8.0
func (r *MemoryRepository) SetRemote(name, url string) error
SetRemote sets a remote repository URL
func (*MemoryRepository) Status ¶ added in v0.8.0
func (r *MemoryRepository) Status() ([]string, error)
Status returns a list of changed files
type Repository ¶ added in v0.8.0
type Repository struct {
// contains filtered or unexported fields
}
Repository implements GitRepository using go-git library
func (*Repository) Add ¶ added in v0.8.0
func (r *Repository) Add(patterns ...string) error
Add stages files for commit
func (*Repository) Commit ¶ added in v0.8.0
func (r *Repository) Commit(message string) error
Commit creates a commit with the given message
func (*Repository) Exists ¶ added in v0.8.0
func (r *Repository) Exists() (bool, error)
Exists checks if a git repository exists at the working directory
func (*Repository) GetWorkingDirectory ¶ added in v0.8.0
func (r *Repository) GetWorkingDirectory() string
GetWorkingDirectory returns the path to the working directory
func (*Repository) HasRemote ¶ added in v0.8.0
func (r *Repository) HasRemote() (bool, error)
HasRemote checks if any remote is configured
func (*Repository) Init ¶ added in v0.8.0
func (r *Repository) Init(branch string) error
Init initializes a git repository with the specified branch name
func (*Repository) Push ¶ added in v0.8.0
func (r *Repository) Push() error
Push pushes commits to the remote repository
func (*Repository) PushContext ¶ added in v0.8.0
func (r *Repository) PushContext(ctx context.Context) error
PushContext pushes commits to the remote repository with context
func (*Repository) SetRemote ¶ added in v0.8.0
func (r *Repository) SetRemote(name, url string) error
SetRemote sets a remote repository URL
func (*Repository) Status ¶ added in v0.8.0
func (r *Repository) Status() ([]string, error)
Status returns a list of changed files