Documentation
¶
Index ¶
- Variables
- func AheadBehind(repoPath, base, branch string) (ahead int, behind int, err error)
- func BranchDelete(repoPath, branch string, force bool) error
- func BranchList(repoPath string) ([]string, error)
- func ChangedBadge(count int) string
- func CreateWorkspace(cfg *Config, profile *Profile, profileName, name string, ...) error
- func CurrentBranch(path string) (string, error)
- func ExpandPath(path string) string
- func FetchAll(repoPath string) error
- func FormatRepoStatusCompact(repoName string, changedCount int) string
- func GetWorkspacePath(cfg *Config, profileName, name string) string
- func IsFzfAvailable() bool
- func ParseWorkspaceLabel(label string) (profileName, workspaceName string, err error)
- func PrintError(format string, args ...interface{})
- func PrintHeader(format string, args ...interface{})
- func PrintInfo(format string, args ...interface{})
- func PrintRepoStatus(repoName, branchName string, changedCount int, ahead, behind int, ...)
- func PrintSuccess(format string, args ...interface{})
- func PrintWarning(format string, args ...interface{})
- func RemoteBranchList(repoPath string) ([]string, error)
- func RemoveWorkspace(cfg *Config, profile *Profile, profileName, name string, ...) error
- func SelectBranch(repoPath, prompt, defaultBranch string) (string, error)
- func SelectProfile(names []string) (string, error)
- func SelectWithFzf(items []string, prompt, header string) (string, error)
- func SelectWorkspace(items []string) (string, error)
- func StatusChangedCount(path string) (int, error)
- func StatusPorcelain(path string) (string, error)
- func WorkspaceLabels(workspaces []WorkspaceInfo) []string
- func WorktreeAdd(repoPath, worktreePath, branch, base string) error
- func WorktreeRemove(repoPath, worktreePath string, force bool) error
- type Config
- type Hook
- type Hooks
- type Profile
- type Repo
- type RepoStatus
- type WorkspaceInfo
- type WorktreeEntry
Constants ¶
This section is empty.
Variables ¶
var ( // SuccessStyle is used for success messages (green). SuccessStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("2")) // WarningStyle is used for warning messages (yellow). WarningStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("3")) // ErrorStyle is used for error messages (red). ErrorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) // InfoStyle is used for informational messages (blue). InfoStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("4")) // RepoNameStyle is used for rendering repository names (bold). RepoNameStyle = lipgloss.NewStyle().Bold(true) // BranchNameStyle is used for rendering branch names (cyan). BranchNameStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("6")) // ProfileNameStyle is used for rendering profile names (magenta bold). ProfileNameStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("5")).Bold(true) // DimStyle is used for less important text. DimStyle = lipgloss.NewStyle().Faint(true) // CleanBadge shows a clean status indicator. CleanBadge = SuccessStyle.Render("\u2713 clean") // HeaderStyle is used for section headers. HeaderStyle = lipgloss.NewStyle().Bold(true).Underline(true) )
Style definitions using lipgloss.
Functions ¶
func AheadBehind ¶
AheadBehind returns the number of commits ahead and behind between branch and base. Equivalent to: git -C <repoPath> rev-list --count --left-right <base>...<branch>
func BranchDelete ¶
BranchDelete deletes a local branch. Equivalent to: git -C <repoPath> branch -d <branch>
func BranchList ¶
BranchList returns the list of local branch names for a repository. Equivalent to: git -C <repoPath> branch --list --format=%(refname:short)
func ChangedBadge ¶
ChangedBadge returns a styled changed files indicator.
func CreateWorkspace ¶
func CreateWorkspace(cfg *Config, profile *Profile, profileName, name string, baseBranches map[string]string) error
CreateWorkspace creates a new workspace with worktrees for all repos in the profile.
func CurrentBranch ¶
CurrentBranch returns the current branch name of a worktree or repo.
func ExpandPath ¶
ExpandPath expands ~ to the user's home directory.
func FormatRepoStatusCompact ¶
FormatRepoStatusCompact returns a compact repo status string for list view.
func GetWorkspacePath ¶
GetWorkspacePath returns the full path for a workspace.
func IsFzfAvailable ¶
func IsFzfAvailable() bool
IsFzfAvailable checks whether fzf is installed and available in PATH.
func ParseWorkspaceLabel ¶
ParseWorkspaceLabel extracts profile and workspace name from a label.
func PrintError ¶
func PrintError(format string, args ...interface{})
PrintError prints an error message with a red cross.
func PrintHeader ¶
func PrintHeader(format string, args ...interface{})
PrintHeader prints a section header.
func PrintInfo ¶
func PrintInfo(format string, args ...interface{})
PrintInfo prints an informational message.
func PrintRepoStatus ¶
func PrintRepoStatus(repoName, branchName string, changedCount int, ahead, behind int, defaultBase string)
PrintRepoStatus prints a formatted status line for a repo within a workspace.
func PrintSuccess ¶
func PrintSuccess(format string, args ...interface{})
PrintSuccess prints a success message with a green checkmark.
func PrintWarning ¶
func PrintWarning(format string, args ...interface{})
PrintWarning prints a warning message with a yellow warning sign.
func RemoteBranchList ¶
RemoteBranchList returns the list of remote branch names for a repository. Equivalent to: git -C <repoPath> branch -r --format=%(refname:short)
func RemoveWorkspace ¶
func RemoveWorkspace(cfg *Config, profile *Profile, profileName, name string, deleteBranch, force bool) error
RemoveWorkspace removes a workspace and optionally deletes its branches.
func SelectBranch ¶
SelectBranch gets the branch list for a repo, puts defaultBranch first, and lets the user select via fzf.
func SelectProfile ¶
SelectProfile lets the user select a profile from a list of profile names via fzf.
func SelectWithFzf ¶
SelectWithFzf presents a list of items via fzf for the user to select from. Returns the selected item or an error if fzf exits non-zero (e.g., user pressed Esc).
func SelectWorkspace ¶
SelectWorkspace lets the user select a workspace from a list of workspace labels via fzf.
func StatusChangedCount ¶
StatusChangedCount returns the number of changed files in a worktree.
func StatusPorcelain ¶
StatusPorcelain returns the porcelain status output for a given path. Equivalent to: git -C <path> status --porcelain
func WorkspaceLabels ¶
func WorkspaceLabels(workspaces []WorkspaceInfo) []string
WorkspaceLabels returns a list of formatted workspace labels for fzf selection.
func WorktreeAdd ¶
WorktreeAdd creates a new worktree with a new branch. Equivalent to: git -C <repoPath> worktree add <worktreePath> -b <branch> <base>
func WorktreeRemove ¶
WorktreeRemove removes an existing worktree. Equivalent to: git -C <repoPath> worktree remove <worktreePath>
Types ¶
type Config ¶
type Config struct {
BaseDir string `mapstructure:"base_dir" yaml:"base_dir"`
DefaultProfile string `mapstructure:"default_profile" yaml:"default_profile"`
Profiles map[string]Profile `mapstructure:"profiles" yaml:"profiles"`
}
Config is the top-level configuration structure.
func LoadConfig ¶
LoadConfig reads the configuration from ~/.config/mgv/config.yaml.
func (*Config) GetProfile ¶
GetProfile returns the named profile from the config. If name is empty, returns the default profile.
func (*Config) ProfileNames ¶
ProfileNames returns a sorted list of profile names.
type Hook ¶
type Hook struct {
Repo string `mapstructure:"repo" yaml:"repo"`
Run string `mapstructure:"run" yaml:"run"`
}
Hook represents a post-create hook to run after workspace creation.
type Hooks ¶
type Hooks struct {
PostCreate []Hook `mapstructure:"post_create" yaml:"post_create"`
}
Hooks holds the different hook stages.
type Profile ¶
type Profile struct {
Repos []Repo `mapstructure:"repos" yaml:"repos"`
Hooks Hooks `mapstructure:"hooks" yaml:"hooks"`
}
Profile represents a named collection of repositories and their hooks.
type Repo ¶
type Repo struct {
Name string `mapstructure:"name" yaml:"name"`
Path string `mapstructure:"path" yaml:"path"`
DefaultBase string `mapstructure:"default_base" yaml:"default_base"`
}
Repo represents a single git repository within a profile.
func (*Repo) GetDefaultBase ¶
GetRepoDefaultBase returns the default base branch for a repo, falling back to "main" if not set.
type RepoStatus ¶
type RepoStatus struct {
RepoName string
BranchName string
ChangedCount int
Ahead int
Behind int
DefaultBase string
Exists bool
}
RepoStatus represents the status of a single repo within a workspace.
type WorkspaceInfo ¶
type WorkspaceInfo struct {
ProfileName string
WorkspaceName string
Path string
RepoStatuses []RepoStatus
}
WorkspaceInfo represents summary info about a workspace.
func ListWorkspaces ¶
func ListWorkspaces(cfg *Config, profileName string) ([]WorkspaceInfo, error)
ListWorkspaces scans the base_dir for workspaces and returns their info. If profileName is empty, all profiles are scanned.
type WorktreeEntry ¶
WorktreeEntry represents a single worktree from porcelain output.
func WorktreeList ¶
func WorktreeList(repoPath string) ([]WorktreeEntry, error)
WorktreeList lists worktrees for a repository in porcelain format. Equivalent to: git -C <repoPath> worktree list --porcelain