Documentation
¶
Index ¶
- type Commit
- type Driver
- type GitDriver
- func (g *GitDriver) Checkout(ctx context.Context, path, branch string, create bool) error
- func (g *GitDriver) Clone(ctx context.Context, url, path, branch string) error
- func (g *GitDriver) Commit(ctx context.Context, path, message string, all bool) error
- func (g *GitDriver) CurrentBranch(ctx context.Context, path string) (string, error)
- func (g *GitDriver) Diff(ctx context.Context, path string) (string, error)
- func (g *GitDriver) Fetch(ctx context.Context, path string) error
- func (g *GitDriver) Grep(ctx context.Context, path, pattern string) ([]GrepResult, error)
- func (g *GitDriver) Log(ctx context.Context, path string, limit int) ([]Commit, error)
- func (g *GitDriver) Name() string
- func (g *GitDriver) Pull(ctx context.Context, path string) error
- func (g *GitDriver) Push(ctx context.Context, path string) error
- func (g *GitDriver) Status(ctx context.Context, path string) (*RepoStatus, error)
- func (g *GitDriver) WorktreeAdd(ctx context.Context, path, name, branch string) (string, error)
- func (g *GitDriver) WorktreeList(ctx context.Context, path string) ([]Worktree, error)
- func (g *GitDriver) WorktreeRemove(ctx context.Context, path, name string) error
- type GrepResult
- type RepoStatus
- type SaplingDriver
- func (s *SaplingDriver) Checkout(ctx context.Context, path, branch string, create bool) error
- func (s *SaplingDriver) Clone(ctx context.Context, url, path, branch string) error
- func (s *SaplingDriver) Commit(ctx context.Context, path, message string, all bool) error
- func (s *SaplingDriver) CurrentBranch(ctx context.Context, path string) (string, error)
- func (s *SaplingDriver) Diff(ctx context.Context, path string) (string, error)
- func (s *SaplingDriver) Fetch(ctx context.Context, path string) error
- func (s *SaplingDriver) Grep(ctx context.Context, path, pattern string) ([]GrepResult, error)
- func (s *SaplingDriver) Log(ctx context.Context, path string, limit int) ([]Commit, error)
- func (s *SaplingDriver) Name() string
- func (s *SaplingDriver) Pull(ctx context.Context, path string) error
- func (s *SaplingDriver) Push(ctx context.Context, path string) error
- func (s *SaplingDriver) Status(ctx context.Context, path string) (*RepoStatus, error)
- func (s *SaplingDriver) WorktreeAdd(ctx context.Context, path, name, branch string) (string, error)
- func (s *SaplingDriver) WorktreeList(ctx context.Context, path string) ([]Worktree, error)
- func (s *SaplingDriver) WorktreeRemove(ctx context.Context, path, name string) error
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct {
Hash string `json:"hash"`
Author string `json:"author"`
Date string `json:"date"`
Message string `json:"message"`
}
Commit represents a VCS commit.
type Driver ¶
type Driver interface {
// Name returns the driver name ("git" or "sl").
Name() string
// Clone clones a repository to the given path.
Clone(ctx context.Context, url, path, branch string) error
// Pull pulls the current branch from the remote.
Pull(ctx context.Context, path string) error
// Push pushes the current branch to the remote.
Push(ctx context.Context, path string) error
// Fetch fetches from the remote without merging.
Fetch(ctx context.Context, path string) error
// Checkout switches to the given branch.
// If create is true, creates the branch first.
Checkout(ctx context.Context, path, branch string, create bool) error
// Status returns the current status of the repository.
Status(ctx context.Context, path string) (*RepoStatus, error)
// Commit creates a commit with the given message.
// If all is true, stages all modified files first.
Commit(ctx context.Context, path, message string, all bool) error
// CurrentBranch returns the name of the current branch.
CurrentBranch(ctx context.Context, path string) (string, error)
// Log returns the last n commits.
Log(ctx context.Context, path string, limit int) ([]Commit, error)
// Diff returns the diff of uncommitted changes.
Diff(ctx context.Context, path string) (string, error)
// Grep searches for a pattern in the repository.
Grep(ctx context.Context, path, pattern string) ([]GrepResult, error)
// WorktreeAdd creates a new worktree.
// Returns the path to the new worktree.
WorktreeAdd(ctx context.Context, path, name, branch string) (string, error)
// WorktreeList lists all worktrees.
WorktreeList(ctx context.Context, path string) ([]Worktree, error)
// WorktreeRemove removes a worktree.
WorktreeRemove(ctx context.Context, path, name string) error
}
Driver is the interface for VCS operations. Both git and Sapling implement this interface.
func Detect ¶
Detect auto-detects the VCS driver for a repository path by checking for .git or .sl directories.
func DetectOrDefault ¶
DetectOrDefault tries to detect the VCS, falling back to the given default.
func DriverByName ¶
DriverByName returns a driver by name.
type GitDriver ¶
type GitDriver struct{}
GitDriver implements Driver for git.
func NewGitDriver ¶
func NewGitDriver() *GitDriver
func (*GitDriver) CurrentBranch ¶
func (*GitDriver) WorktreeAdd ¶
func (*GitDriver) WorktreeList ¶
type GrepResult ¶
type GrepResult struct {
File string `json:"file"`
Line int `json:"line"`
Content string `json:"content"`
}
GrepResult represents a single grep match.
type RepoStatus ¶
type RepoStatus struct {
Branch string `json:"branch"`
Dirty bool `json:"dirty"`
Ahead int `json:"ahead"`
Behind int `json:"behind"`
Modified []string `json:"modified,omitempty"`
Untracked []string `json:"untracked,omitempty"`
Staged []string `json:"staged,omitempty"`
}
RepoStatus represents the VCS status of a repository.
type SaplingDriver ¶
type SaplingDriver struct{}
SaplingDriver implements Driver for Sapling (sl).
func NewSaplingDriver ¶
func NewSaplingDriver() *SaplingDriver
func (*SaplingDriver) Clone ¶
func (s *SaplingDriver) Clone(ctx context.Context, url, path, branch string) error
func (*SaplingDriver) CurrentBranch ¶
func (*SaplingDriver) Grep ¶
func (s *SaplingDriver) Grep(ctx context.Context, path, pattern string) ([]GrepResult, error)
func (*SaplingDriver) Name ¶
func (s *SaplingDriver) Name() string
func (*SaplingDriver) Status ¶
func (s *SaplingDriver) Status(ctx context.Context, path string) (*RepoStatus, error)
func (*SaplingDriver) WorktreeAdd ¶
WorktreeAdd for Sapling falls back to cloning since sl doesn't support worktrees.
func (*SaplingDriver) WorktreeList ¶
func (*SaplingDriver) WorktreeRemove ¶
func (s *SaplingDriver) WorktreeRemove(ctx context.Context, path, name string) error
Click to show internal directories.
Click to hide internal directories.