Documentation
¶
Overview ¶
Package vcs provides an abstraction layer over version control systems. It supports Jujutsu (JJ) as the primary VCS with automatic fallback to Git.
Index ¶
- func GetGitVersion() (string, error)
- func GetJJVersion() (string, error)
- func GetVCSInfo(repoPath string) (hasJJ bool, hasGit bool, isColocated bool)
- func IsColocated(repoPath string) bool
- type Bookmark
- type ChangeStrategy
- type DetectOptions
- type GitClient
- func (g *GitClient) AbandonChanges() error
- func (g *GitClient) CreateBookmark(name string, base string) error
- func (g *GitClient) CreateWorktree(path string, branch string) error
- func (g *GitClient) DescribeWIP(message string) error
- func (g *GitClient) GetCurrentBookmark() (string, error)
- func (g *GitClient) GetCurrentRevision() (*Revision, error)
- func (g *GitClient) GetStatus() (*WorkingCopyStatus, error)
- func (g *GitClient) HasUncommittedChanges() (bool, error)
- func (g *GitClient) ListBookmarks() ([]Bookmark, error)
- func (g *GitClient) ListRecentRevisions(limit int) ([]Revision, error)
- func (g *GitClient) ListWorktrees() ([]Worktree, error)
- func (g *GitClient) RepoPath() string
- func (g *GitClient) SwitchTo(target string, opts SwitchOptions) error
- func (g *GitClient) Type() VCSType
- type JJClient
- func (j *JJClient) AbandonChanges() error
- func (j *JJClient) CreateBookmark(name string, base string) error
- func (j *JJClient) CreateWorktree(path string, name string) error
- func (j *JJClient) DescribeWIP(message string) error
- func (j *JJClient) GetCurrentBookmark() (string, error)
- func (j *JJClient) GetCurrentRevision() (*Revision, error)
- func (j *JJClient) GetStatus() (*WorkingCopyStatus, error)
- func (j *JJClient) HasUncommittedChanges() (bool, error)
- func (j *JJClient) ListBookmarks() ([]Bookmark, error)
- func (j *JJClient) ListRecentRevisions(limit int) ([]Revision, error)
- func (j *JJClient) ListWorktrees() ([]Worktree, error)
- func (j *JJClient) RepoPath() string
- func (j *JJClient) SwitchTo(target string, opts SwitchOptions) error
- func (j *JJClient) Type() VCSType
- type Revision
- type SwitchOptions
- type VCS
- type VCSPreference
- type VCSType
- type WorkingCopyStatus
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGitVersion ¶
GetGitVersion returns the installed Git version
func GetJJVersion ¶
GetJJVersion returns the installed JJ version
func GetVCSInfo ¶
GetVCSInfo returns information about what VCS is available at the path
func IsColocated ¶
IsColocated checks if the repository is a JJ+Git colocated repository
Types ¶
type Bookmark ¶
type Bookmark struct {
// Name is the bookmark/branch name
Name string
// RevisionID is the revision this bookmark points to
RevisionID string
// IsRemote indicates if this is a remote tracking bookmark
IsRemote bool
// Upstream is the remote tracking bookmark (if any)
Upstream string
}
Bookmark represents a named reference (branch in Git, bookmark in JJ)
type ChangeStrategy ¶
type ChangeStrategy int
ChangeStrategy defines how to handle uncommitted changes during workspace switches
const ( // KeepAsWIP keeps changes as a separate WIP revision (JJ) or stash (Git) KeepAsWIP ChangeStrategy = iota // BringAlong keeps changes as parent of new location (JJ) or stash pop (Git) BringAlong // Abandon discards uncommitted changes Abandon )
func ParseChangeStrategy ¶
func ParseChangeStrategy(s string) (ChangeStrategy, error)
ParseChangeStrategy converts a string to ChangeStrategy
func (ChangeStrategy) String ¶
func (s ChangeStrategy) String() string
type DetectOptions ¶
type DetectOptions struct {
// Preference is the user's VCS preference
Preference VCSPreference
}
DetectOptions configures VCS detection behavior
func DefaultDetectOptions ¶
func DefaultDetectOptions() DetectOptions
DefaultDetectOptions returns the default detection options
type GitClient ¶
type GitClient struct {
// contains filtered or unexported fields
}
GitClient implements the VCS interface for Git
func NewGitClient ¶
NewGitClient creates a new Git client for the given repository path
func (*GitClient) AbandonChanges ¶
AbandonChanges discards all uncommitted changes
func (*GitClient) CreateBookmark ¶
CreateBookmark creates a new branch at the specified base
func (*GitClient) CreateWorktree ¶
CreateWorktree creates a new Git worktree
func (*GitClient) DescribeWIP ¶
DescribeWIP is a no-op for Git (changes are always in working tree)
func (*GitClient) GetCurrentBookmark ¶
GetCurrentBookmark returns the current branch name
func (*GitClient) GetCurrentRevision ¶
GetCurrentRevision returns the current revision
func (*GitClient) GetStatus ¶
func (g *GitClient) GetStatus() (*WorkingCopyStatus, error)
GetStatus returns the working copy status
func (*GitClient) HasUncommittedChanges ¶
HasUncommittedChanges checks if there are uncommitted changes
func (*GitClient) ListBookmarks ¶
ListBookmarks returns all branches
func (*GitClient) ListRecentRevisions ¶
ListRecentRevisions returns recent commits
func (*GitClient) ListWorktrees ¶
ListWorktrees returns all Git worktrees
type JJClient ¶
type JJClient struct {
// contains filtered or unexported fields
}
JJClient implements the VCS interface for Jujutsu
func NewJJClient ¶
NewJJClient creates a new JJ client for the given repository path
func (*JJClient) AbandonChanges ¶
AbandonChanges abandons the current change
func (*JJClient) CreateBookmark ¶
CreateBookmark creates a new bookmark at the specified base
func (*JJClient) CreateWorktree ¶
CreateWorktree creates a new JJ workspace (worktree equivalent)
func (*JJClient) DescribeWIP ¶
DescribeWIP sets the description for the current change
func (*JJClient) GetCurrentBookmark ¶
GetCurrentBookmark returns the current bookmark name
func (*JJClient) GetCurrentRevision ¶
GetCurrentRevision returns the current revision
func (*JJClient) GetStatus ¶
func (j *JJClient) GetStatus() (*WorkingCopyStatus, error)
GetStatus returns the working copy status
func (*JJClient) HasUncommittedChanges ¶
HasUncommittedChanges checks if there are uncommitted changes
func (*JJClient) ListBookmarks ¶
ListBookmarks returns all bookmarks
func (*JJClient) ListRecentRevisions ¶
ListRecentRevisions returns recent revisions
func (*JJClient) ListWorktrees ¶
ListWorktrees returns all JJ workspaces
type Revision ¶
type Revision struct {
// ID is the unique identifier (commit SHA in Git, change ID in JJ)
ID string
// ShortID is a shortened version of the ID for display
ShortID string
// Description is the commit/change message (first line)
Description string
// Author is the revision author
Author string
// Timestamp is when the revision was created
Timestamp time.Time
// Bookmarks are the bookmarks/branches pointing to this revision
Bookmarks []string
// IsCurrent indicates if this is the current working copy revision
IsCurrent bool
}
Revision represents a VCS revision (commit in Git, change in JJ)
type SwitchOptions ¶
type SwitchOptions struct {
// ChangeStrategy determines how to handle uncommitted changes
ChangeStrategy ChangeStrategy
// CreateIfMissing creates the bookmark/branch if it doesn't exist
CreateIfMissing bool
// BaseRevision is the base for new bookmark creation (empty = current)
BaseRevision string
}
SwitchOptions configures how to handle a workspace switch
type VCS ¶
type VCS interface {
// Type returns the VCS type (jj or git)
Type() VCSType
// RepoPath returns the root path of the repository
RepoPath() string
// GetStatus returns the working copy status
GetStatus() (*WorkingCopyStatus, error)
// HasUncommittedChanges returns true if there are uncommitted changes
HasUncommittedChanges() (bool, error)
// GetCurrentRevision returns the current revision
GetCurrentRevision() (*Revision, error)
// GetCurrentBookmark returns the current bookmark/branch name (may be empty)
GetCurrentBookmark() (string, error)
// SwitchTo switches to the target revision or bookmark
SwitchTo(target string, opts SwitchOptions) error
// CreateBookmark creates a new bookmark/branch
CreateBookmark(name string, base string) error
// DescribeWIP describes the current change as WIP (JJ: describe, Git: no-op)
DescribeWIP(message string) error
// AbandonChanges abandons uncommitted changes
AbandonChanges() error
// ListBookmarks returns all bookmarks/branches
ListBookmarks() ([]Bookmark, error)
// ListRecentRevisions returns recent revisions for display
ListRecentRevisions(limit int) ([]Revision, error)
// CreateWorktree creates a new worktree at the specified path
CreateWorktree(path string, bookmark string) error
// ListWorktrees returns all worktrees
ListWorktrees() ([]Worktree, error)
}
VCS is the abstraction interface over JJ and Git operations
func Detect ¶
Detect detects and returns the appropriate VCS client for the given repository path. It respects user preferences and falls back appropriately.
func DetectWithOptions ¶
func DetectWithOptions(repoPath string, opts DetectOptions) (VCS, error)
DetectWithOptions detects VCS with custom options
type VCSPreference ¶
type VCSPreference string
VCSPreference represents the user's preferred VCS
const ( // PreferenceAuto automatically detects VCS (JJ preferred if available) PreferenceAuto VCSPreference = "auto" // PreferenceJJ forces JJ usage PreferenceJJ VCSPreference = "jj" // PreferenceGit forces Git usage PreferenceGit VCSPreference = "git" )
type WorkingCopyStatus ¶
type WorkingCopyStatus struct {
// HasChanges indicates if there are uncommitted changes
HasChanges bool
// ModifiedFiles is the count of modified files
ModifiedFiles int
// AddedFiles is the count of newly added files
AddedFiles int
// DeletedFiles is the count of deleted files
DeletedFiles int
// ConflictedFiles is the count of files with conflicts
ConflictedFiles int
}
WorkingCopyStatus represents the status of the working copy
type Worktree ¶
type Worktree struct {
// Path is the filesystem path to the worktree
Path string
// Name is the worktree name (JJ workspace name)
Name string
// Bookmark is the associated bookmark/branch
Bookmark string
// RevisionID is the current revision in this worktree
RevisionID string
// IsCurrent indicates if this is the current worktree
IsCurrent bool
}
Worktree represents a working tree/workspace