Documentation
¶
Index ¶
- Variables
- func FindVCSRoot(path string, vcsType VCSType) (string, error)
- func IsToolAvailable(name string) bool
- type CommitOptions
- type FileChange
- type FileStatus
- type GitProvider
- func (g *GitProvider) AmendCommit(message string) error
- func (g *GitProvider) Commit(message string) error
- func (g *GitProvider) Fetch() error
- func (g *GitProvider) GetBranch() (string, error)
- func (g *GitProvider) GetChangedFiles() ([]FileChange, error)
- func (g *GitProvider) GetDiff() (string, error)
- func (g *GitProvider) GetFileDiff(path string) (string, error)
- func (g *GitProvider) GetInteractiveCommand() string
- func (g *GitProvider) GetLogCommand() string
- func (g *GitProvider) GetStatus() (*VCSStatus, error)
- func (g *GitProvider) Name() string
- func (g *GitProvider) Pull() error
- func (g *GitProvider) Push() error
- func (g *GitProvider) PushWithOptions(opts PushOptions) error
- func (g *GitProvider) Stage(path string) error
- func (g *GitProvider) StageAll() error
- func (g *GitProvider) Type() VCSType
- func (g *GitProvider) Unstage(path string) error
- func (g *GitProvider) UnstageAll() error
- func (g *GitProvider) WorkDir() string
- type JujutsuProvider
- func (j *JujutsuProvider) Abandon() error
- func (j *JujutsuProvider) AmendCommit(message string) error
- func (j *JujutsuProvider) Commit(message string) error
- func (j *JujutsuProvider) Describe(message string) error
- func (j *JujutsuProvider) Edit(changeID string) error
- func (j *JujutsuProvider) Fetch() error
- func (j *JujutsuProvider) GetBranch() (string, error)
- func (j *JujutsuProvider) GetChangedFiles() ([]FileChange, error)
- func (j *JujutsuProvider) GetDiff() (string, error)
- func (j *JujutsuProvider) GetFileDiff(path string) (string, error)
- func (j *JujutsuProvider) GetInteractiveCommand() string
- func (j *JujutsuProvider) GetLogCommand() string
- func (j *JujutsuProvider) GetStatus() (*VCSStatus, error)
- func (j *JujutsuProvider) Name() string
- func (j *JujutsuProvider) New() error
- func (j *JujutsuProvider) Pull() error
- func (j *JujutsuProvider) Push() error
- func (j *JujutsuProvider) PushWithOptions(opts PushOptions) error
- func (j *JujutsuProvider) Squash() error
- func (j *JujutsuProvider) Stage(path string) error
- func (j *JujutsuProvider) StageAll() error
- func (j *JujutsuProvider) Type() VCSType
- func (j *JujutsuProvider) Unstage(path string) error
- func (j *JujutsuProvider) UnstageAll() error
- func (j *JujutsuProvider) WorkDir() string
- type PushOptions
- type VCSProvider
- type VCSStatus
- type VCSType
Constants ¶
This section is empty.
Variables ¶
var ErrNoVCSFound = errors.New("no version control system found")
ErrNoVCSFound is returned when no version control system is detected
var ErrNotImplemented = errors.New("feature not implemented for this VCS")
ErrNotImplemented is returned when a feature is not implemented for a VCS
Functions ¶
func FindVCSRoot ¶
FindVCSRoot finds the root directory of the VCS repository
func IsToolAvailable ¶
IsToolAvailable checks if a command-line tool is available in PATH
Types ¶
type CommitOptions ¶
type CommitOptions struct {
Message string // Commit message
Amend bool // Amend the last commit
AllowEmpty bool // Allow empty commits
Author string // Override author
Files []string // Specific files to commit (empty = all staged)
}
CommitOptions contains options for the Commit operation
type FileChange ¶
type FileChange struct {
Path string // File path relative to repository root
Status FileStatus // Type of change
IsStaged bool // Whether the change is staged for commit
OldPath string // Original path for renames/copies
Additions int // Lines added, from `git diff --numstat` (0 for untracked/binary files)
Deletions int // Lines removed, from `git diff --numstat` (0 for untracked/binary files)
}
FileChange represents a changed file in the working directory
type FileStatus ¶
type FileStatus int
FileStatus represents the status of a file in version control
const ( FileUnmodified FileStatus = iota FileModified FileAdded FileDeleted FileRenamed FileCopied FileUntracked FileIgnored FileConflict )
func (FileStatus) String ¶
func (s FileStatus) String() string
String returns a single character representing the file status
type GitProvider ¶
type GitProvider struct {
// contains filtered or unexported fields
}
GitProvider implements VCSProvider for Git repositories
func NewGitProvider ¶
func NewGitProvider(path string) (*GitProvider, error)
NewGitProvider creates a new Git provider for the given directory
func (*GitProvider) AmendCommit ¶
func (g *GitProvider) AmendCommit(message string) error
func (*GitProvider) Commit ¶
func (g *GitProvider) Commit(message string) error
func (*GitProvider) Fetch ¶
func (g *GitProvider) Fetch() error
func (*GitProvider) GetBranch ¶
func (g *GitProvider) GetBranch() (string, error)
func (*GitProvider) GetChangedFiles ¶
func (g *GitProvider) GetChangedFiles() ([]FileChange, error)
GetChangedFiles returns the current working-tree/index status as a flat list of FileChange entries. It orchestrates three pure steps: run the porcelain status + numstat git commands, parse the porcelain output (parsePorcelainV2Z), then merge in per-file insertion/deletion counts (mergeNumstat).
func (*GitProvider) GetDiff ¶
func (g *GitProvider) GetDiff() (string, error)
func (*GitProvider) GetFileDiff ¶
func (g *GitProvider) GetFileDiff(path string) (string, error)
func (*GitProvider) GetInteractiveCommand ¶
func (g *GitProvider) GetInteractiveCommand() string
func (*GitProvider) GetLogCommand ¶
func (g *GitProvider) GetLogCommand() string
func (*GitProvider) GetStatus ¶
func (g *GitProvider) GetStatus() (*VCSStatus, error)
func (*GitProvider) Name ¶
func (g *GitProvider) Name() string
func (*GitProvider) Pull ¶
func (g *GitProvider) Pull() error
func (*GitProvider) Push ¶
func (g *GitProvider) Push() error
func (*GitProvider) PushWithOptions ¶
func (g *GitProvider) PushWithOptions(opts PushOptions) error
func (*GitProvider) Stage ¶
func (g *GitProvider) Stage(path string) error
func (*GitProvider) StageAll ¶
func (g *GitProvider) StageAll() error
func (*GitProvider) Type ¶
func (g *GitProvider) Type() VCSType
func (*GitProvider) Unstage ¶
func (g *GitProvider) Unstage(path string) error
func (*GitProvider) UnstageAll ¶
func (g *GitProvider) UnstageAll() error
func (*GitProvider) WorkDir ¶
func (g *GitProvider) WorkDir() string
type JujutsuProvider ¶
type JujutsuProvider struct {
// contains filtered or unexported fields
}
JujutsuProvider implements VCSProvider for Jujutsu repositories
func NewJujutsuProvider ¶
func NewJujutsuProvider(path string) (*JujutsuProvider, error)
NewJujutsuProvider creates a new Jujutsu provider for the given directory
func (*JujutsuProvider) Abandon ¶
func (j *JujutsuProvider) Abandon() error
Abandon abandons the current change
func (*JujutsuProvider) AmendCommit ¶
func (j *JujutsuProvider) AmendCommit(message string) error
AmendCommit updates the current change's description
func (*JujutsuProvider) Commit ¶
func (j *JujutsuProvider) Commit(message string) error
Commit in jj creates a new empty change after the current one
func (*JujutsuProvider) Describe ¶
func (j *JujutsuProvider) Describe(message string) error
Describe updates the description of a change
func (*JujutsuProvider) Edit ¶
func (j *JujutsuProvider) Edit(changeID string) error
Edit starts editing a change
func (*JujutsuProvider) Fetch ¶
func (j *JujutsuProvider) Fetch() error
func (*JujutsuProvider) GetBranch ¶
func (j *JujutsuProvider) GetBranch() (string, error)
func (*JujutsuProvider) GetChangedFiles ¶
func (j *JujutsuProvider) GetChangedFiles() ([]FileChange, error)
func (*JujutsuProvider) GetDiff ¶
func (j *JujutsuProvider) GetDiff() (string, error)
func (*JujutsuProvider) GetFileDiff ¶
func (j *JujutsuProvider) GetFileDiff(path string) (string, error)
func (*JujutsuProvider) GetInteractiveCommand ¶
func (j *JujutsuProvider) GetInteractiveCommand() string
func (*JujutsuProvider) GetLogCommand ¶
func (j *JujutsuProvider) GetLogCommand() string
func (*JujutsuProvider) GetStatus ¶
func (j *JujutsuProvider) GetStatus() (*VCSStatus, error)
func (*JujutsuProvider) Name ¶
func (j *JujutsuProvider) Name() string
func (*JujutsuProvider) New ¶
func (j *JujutsuProvider) New() error
New creates a new change after the current one
func (*JujutsuProvider) Pull ¶
func (j *JujutsuProvider) Pull() error
func (*JujutsuProvider) Push ¶
func (j *JujutsuProvider) Push() error
func (*JujutsuProvider) PushWithOptions ¶
func (j *JujutsuProvider) PushWithOptions(opts PushOptions) error
func (*JujutsuProvider) Squash ¶
func (j *JujutsuProvider) Squash() error
Squash squashes the current change into its parent
func (*JujutsuProvider) Stage ¶
func (j *JujutsuProvider) Stage(path string) error
Stage in jj is a no-op since changes are automatically included in @
func (*JujutsuProvider) StageAll ¶
func (j *JujutsuProvider) StageAll() error
func (*JujutsuProvider) Type ¶
func (j *JujutsuProvider) Type() VCSType
func (*JujutsuProvider) Unstage ¶
func (j *JujutsuProvider) Unstage(path string) error
Unstage in jj means restoring a file to its parent's version
func (*JujutsuProvider) UnstageAll ¶
func (j *JujutsuProvider) UnstageAll() error
func (*JujutsuProvider) WorkDir ¶
func (j *JujutsuProvider) WorkDir() string
type PushOptions ¶
type PushOptions struct {
Force bool // Force push (use with caution)
SetUpstream bool // Set upstream tracking reference
Remote string // Remote name (defaults to "origin")
Branch string // Branch name (defaults to current branch)
}
PushOptions contains options for the Push operation
type VCSProvider ¶
type VCSProvider interface {
// Type returns the type of version control system
Type() VCSType
// Name returns the human-readable name of the VCS (e.g., "Git", "Jujutsu")
Name() string
// WorkDir returns the working directory path
WorkDir() string
// GetStatus returns the current status of the working directory
GetStatus() (*VCSStatus, error)
// GetBranch returns the current branch name (Git) or bookmark/change ID (Jujutsu)
GetBranch() (string, error)
// GetChangedFiles returns a list of all changed files
GetChangedFiles() ([]FileChange, error)
// Stage adds a file to the staging area (Git) or marks it for inclusion (Jujutsu)
Stage(path string) error
// StageAll stages all changed files
StageAll() error
// Unstage removes a file from the staging area
Unstage(path string) error
// UnstageAll unstages all files
UnstageAll() error
// Commit creates a new commit with the given message
Commit(message string) error
// AmendCommit amends the last commit (Git) or updates the current change description (Jujutsu)
AmendCommit(message string) error
// Push pushes commits to the remote repository
Push() error
// PushWithOptions pushes with additional options (force, set-upstream, etc.)
PushWithOptions(opts PushOptions) error
// Pull pulls changes from the remote repository
Pull() error
// Fetch fetches changes from the remote without merging
Fetch() error
// GetFileDiff returns the diff for a specific file
GetFileDiff(path string) (string, error)
// GetDiff returns the full diff of uncommitted changes
GetDiff() (string, error)
// GetInteractiveCommand returns the command to open an interactive VCS tool
// For Git: "lazygit" or "tig" if available, otherwise "git status"
// For Jujutsu: "lazyjj" if available, otherwise "jj log"
GetInteractiveCommand() string
// GetLogCommand returns the command to view the commit/change log
GetLogCommand() string
}
VCSProvider defines the interface for version control operations. Implementations exist for Git and Jujutsu.
func NewProvider ¶
func NewProvider(path string) (VCSProvider, error)
NewProvider creates a new VCSProvider for the given directory. It auto-detects the VCS type and returns the appropriate provider.
type VCSStatus ¶
type VCSStatus struct {
// VCS identification
Type VCSType
// Branch/change information
Branch string // Current branch name (Git) or bookmark (Jujutsu)
HeadCommit string // Short SHA (Git) or change ID (Jujutsu)
Description string // Commit message or change description
// Remote tracking
AheadBy int // Commits ahead of upstream
BehindBy int // Commits behind upstream
Upstream string // Name of upstream branch/remote
// Working directory state
HasStaged bool // Has staged changes
HasUnstaged bool // Has unstaged changes
HasUntracked bool // Has untracked files
HasConflicts bool // Has merge/rebase conflicts
IsClean bool // Working directory is clean
// File lists
StagedFiles []FileChange
UnstagedFiles []FileChange
UntrackedFiles []FileChange
ConflictFiles []FileChange
}
VCSStatus represents the current status of the version control system
func (*VCSStatus) AheadBehindString ¶
AheadBehindString returns a formatted string like "+2/-1"
func (*VCSStatus) AllChangedFiles ¶
func (s *VCSStatus) AllChangedFiles() []FileChange
AllChangedFiles returns all files with changes, in display order
func (*VCSStatus) TotalChanges ¶
TotalChanges returns the total number of changed files
type VCSType ¶
type VCSType int
VCSType represents the type of version control system