Documentation
¶
Overview ¶
Package gitstatus implements the git status plugin with staging/unstaging, diff viewing, commit history, branch management, and conflict resolution.
Index ¶
- Constants
- func AbortMerge(workDir string) error
- func AbortRebase(workDir string) error
- func BuildCommitURL(info *GitHubInfo, hash string) string
- func CheckoutBranch(workDir, branchName string) error
- func CountParsedDiffLines(diff *ParsedDiff) int
- func CreateBranch(workDir, branchName string) error
- func DeleteBranch(workDir, branchName string) error
- func DiscardModified(workDir, path string) error
- func DiscardStaged(workDir, path string) error
- func DiscardUntracked(workDir, path string) error
- func ExecuteAmend(workDir, message string) (string, error)
- func ExecuteCommit(workDir, message string) (string, error)
- func ExecuteCommitContext(ctx context.Context, workDir, message string) (string, error)
- func ExecuteFetch(workDir string) (string, error)
- func ExecutePull(workDir string) (string, error)
- func ExecutePullAutostash(workDir string) (string, error)
- func ExecutePullFFOnly(workDir string) (string, error)
- func ExecutePullRebase(workDir string) (string, error)
- func ExecutePush(workDir string, force bool) (string, error)
- func ExecutePushForce(workDir string) (string, error)
- func ExecutePushSetUpstream(workDir string) (string, error)
- func ForceDeleteBranch(workDir, branchName string) error
- func GetCommitCount(workDir string) (int, error)
- func GetCommitDiff(workDir, hash, path string, parentHash string) (string, error)
- func GetCommitFullDiff(workDir, hash string) (string, error)
- func GetCommitHistoryFilteredWithPushStatus(workDir string, opts HistoryFilterOpts) ([]*Commit, *PushStatus, error)
- func GetCommitHistoryWithPushStatus(workDir string, limit int) ([]*Commit, *PushStatus, error)
- func GetCommitHistoryWithPushStatusOffset(workDir string, limit, skip int) ([]*Commit, *PushStatus, error)
- func GetConflictedFiles(workDir string) []string
- func GetDiff(workDir, path string, staged bool) (string, error)
- func GetDiffFromHead(workDir, path string) (string, error)
- func GetFileContentAtRef(workDir, path, ref string) (string, error)
- func GetFileContentFromIndex(workDir, path string) (string, error)
- func GetFileDiffStats(workDir, path string, staged bool) (int, int, error)
- func GetFolderDiff(workDir string, files []*FileEntry) (string, error)
- func GetFullDiff(workDir string, staged bool) (string, error)
- func GetNewFileDiff(workDir, path string) (string, error)
- func GetRemoteName(workDir string) string
- func GetRemoteURL(workDir string) string
- func GetWorkingTreeFileContent(workDir, path string) (string, error)
- func HasRemote(workDir string) bool
- func IsConflictError(err error) bool
- func IsRebaseInProgress(workDir string) bool
- func MinimapScrollTarget(clickRow, minimapHeight, totalLines, visibleLines int) int
- func ParsePushOutput(output string) string
- func PopulatePushStatus(commits []*Commit, pushStatus *PushStatus)
- func RelativeTime(t time.Time) string
- func RenderFileHeader(filename, stats string, width int) string
- func RenderFullFileSideBySide(fullDiff *FullFileDiff, width, startLine, maxLines, horizontalOffset int, ...) string
- func RenderLineDiff(diff *ParsedDiff, width, startLine, maxLines, horizontalOffset int, ...) string
- func RenderMinimap(fullDiff *FullFileDiff, scrollPos, visibleLines, height int) string
- func RenderMultiFileDiff(mfd *MultiFileDiff, mode DiffViewMode, ...) string
- func RenderSideBySide(diff *ParsedDiff, width, startLine, maxLines, horizontalOffset int, ...) string
- func StashApply(workDir, ref string) error
- func StashPop(workDir string) error
- func StashPush(workDir string) error
- type AmendMessageLoadedMsg
- type Branch
- type BranchError
- type BranchErrorMsg
- type BranchListLoadedMsg
- type BranchSwitchSuccessMsg
- type Commit
- func GetCommitDetail(workDir, hash string) (*Commit, error)
- func GetCommitHistory(workDir string, limit int) ([]*Commit, error)
- func GetCommitHistoryFiltered(workDir string, opts HistoryFilterOpts) ([]*Commit, error)
- func GetCommitHistoryWithOffset(workDir string, limit, skip int) ([]*Commit, error)
- type CommitCountLoadedMsg
- type CommitError
- type CommitErrorMsg
- type CommitFile
- type CommitPreviewLoadedMsg
- type CommitStats
- type CommitStatsLoadedMsg
- type CommitSuccessMsg
- type DiffLine
- type DiffLoadedMsg
- type DiffStats
- type DiffViewMode
- type DiscardResultMsg
- type ErrorMsg
- type FetchErrorMsg
- type FetchSuccessClearMsg
- type FetchSuccessMsg
- type FileDiffInfo
- type FileEntry
- type FileStatus
- type FileTree
- func (t *FileTree) AllEntries() []*FileEntry
- func (t *FileTree) HasStagedFiles() bool
- func (t *FileTree) ModifiedStats() (additions, deletions int)
- func (t *FileTree) Refresh() error
- func (t *FileTree) RefreshContext(ctx context.Context) error
- func (t *FileTree) StageAll() error
- func (t *FileTree) StageAllContext(ctx context.Context) error
- func (t *FileTree) StageFile(path string) error
- func (t *FileTree) StagedStats() (additions, deletions int)
- func (t *FileTree) Summary() string
- func (t *FileTree) TotalCount() int
- func (t *FileTree) UnstageAll() error
- func (t *FileTree) UnstageFile(path string) error
- type FilteredCommitsLoadedMsg
- type FocusPane
- type FullFileDiff
- type FullFileDiffLoadedMsg
- type FullFileLine
- type GitHubInfo
- type GraphColumn
- type GraphLine
- type GraphState
- type HighlightSegment
- type HistoryFilterOpts
- type HistorySearchState
- type Hunk
- type InlineDiffLoadedMsg
- type LineType
- type MoreCommitsLoadedMsg
- type MultiFileDiff
- type ParsedDiff
- type Plugin
- func (p *Plugin) BlocksGlobalKeys() bool
- func (p *Plugin) Commands() []plugin.Command
- func (p *Plugin) ConsumesTextInput() bool
- func (p *Plugin) Diagnostics() []plugin.Diagnostic
- func (p *Plugin) FocusContext() string
- func (p *Plugin) ID() string
- func (p *Plugin) Icon() string
- func (p *Plugin) Init(ctx *plugin.Context) error
- func (p *Plugin) IsFocused() bool
- func (p *Plugin) Name() string
- func (p *Plugin) SetFocused(f bool)
- func (p *Plugin) Start() tea.Cmd
- func (p *Plugin) Stop()
- func (p *Plugin) Update(msg tea.Msg) (plugin.Plugin, tea.Cmd)
- func (p *Plugin) View(width, height int) string
- func (p *Plugin) WheelAtBoundary(msg tea.MouseWheelMsg) bool
- type PullAbortedMsg
- type PullErrorMsg
- type PullSuccessClearMsg
- type PullSuccessMsg
- type PushError
- type PushErrorMsg
- type PushStatus
- type PushStatusLoadedMsg
- type PushSuccessClearMsg
- type PushSuccessMsg
- type RecentCommitsLoadedMsg
- type RemoteError
- type RepoDetectedMsg
- type RepoInitDoneMsg
- type SideBySideClipInfo
- type Stash
- type StashError
- type StashErrorMsg
- type StashList
- type StashPopConfirmMsg
- type StashResultMsg
- type StatusSnapshotLoadedMsg
- type SyntaxHighlighter
- type ViewMode
- type WatchEvent
- type WatchEventMsg
- type WatchStartFailedMsg
- type WatchStartedMsg
- type Watcher
- type WordSegment
Constants ¶
const MinimapWidth = 3 // "█▀▀" or "▀▀▀" etc.
MinimapWidth is the total character width of the minimap column (rail + map).
Variables ¶
This section is empty.
Functions ¶
func BuildCommitURL ¶
func BuildCommitURL(info *GitHubInfo, hash string) string
BuildCommitURL constructs a GitHub commit URL.
func CheckoutBranch ¶
CheckoutBranch switches to a branch.
func CountParsedDiffLines ¶ added in v0.81.0
func CountParsedDiffLines(diff *ParsedDiff) int
CountParsedDiffLines counts total lines in a parsed diff (exported for use by workspace plugin).
func CreateBranch ¶
CreateBranch creates a new branch from HEAD.
func DeleteBranch ¶
DeleteBranch deletes a branch.
func DiscardModified ¶
DiscardModified discards unstaged changes to a modified file.
func DiscardStaged ¶
DiscardStaged discards staged changes to a file (unstages and restores).
func DiscardUntracked ¶
DiscardUntracked removes an untracked file.
func ExecuteAmend ¶
ExecuteAmend executes a git commit --amend with the given message.
func ExecuteCommit ¶
ExecuteCommit executes a git commit with the given message. Returns the commit hash on success or an error with git output on failure.
func ExecuteCommitContext ¶ added in v0.94.0
ExecuteCommitContext executes a commit and observes ctx while Git runs.
func ExecutePullAutostash ¶
ExecutePullAutostash runs git pull --rebase --autostash.
func ExecutePullFFOnly ¶
ExecutePullFFOnly runs git pull --ff-only.
func ExecutePullRebase ¶
ExecutePullRebase runs git pull --rebase.
func ExecutePush ¶
ExecutePush performs a git push operation. Returns the output from git and any error encountered.
func ExecutePushForce ¶
ExecutePushForce performs a force push with lease. Returns the output from git and any error encountered.
func ExecutePushSetUpstream ¶
ExecutePushSetUpstream performs a push with upstream tracking. Returns the output from git and any error encountered.
func ForceDeleteBranch ¶
ForceDeleteBranch force-deletes a branch.
func GetCommitCount ¶ added in v0.96.0
GetCommitCount returns the total number of commits reachable from HEAD. Uses `git rev-list --count HEAD`, which is typically cheap (tens of ms even on mid-size repos). Call from a tea.Cmd so a pathological monorepo cannot stall the UI; on failure (empty repo, no HEAD) return an error and leave the count unset in the view.
func GetCommitDiff ¶
GetCommitDiff returns the diff for a specific file in a commit. For merge commits, parentHash should be the first parent so we diff against it instead of using git show's combined diff (which is empty for clean merges).
func GetCommitFullDiff ¶
GetCommitFullDiff returns the full diff for a commit.
func GetCommitHistoryFilteredWithPushStatus ¶
func GetCommitHistoryFilteredWithPushStatus(workDir string, opts HistoryFilterOpts) ([]*Commit, *PushStatus, error)
GetCommitHistoryFilteredWithPushStatus fetches filtered commits and populates push status.
func GetCommitHistoryWithPushStatus ¶
func GetCommitHistoryWithPushStatus(workDir string, limit int) ([]*Commit, *PushStatus, error)
GetCommitHistoryWithPushStatus fetches commits and populates push status.
func GetCommitHistoryWithPushStatusOffset ¶
func GetCommitHistoryWithPushStatusOffset(workDir string, limit, skip int) ([]*Commit, *PushStatus, error)
GetCommitHistoryWithPushStatusOffset fetches commits with offset and populates push status.
func GetConflictedFiles ¶
GetConflictedFiles returns a list of files with merge conflicts.
func GetDiffFromHead ¶ added in v0.81.0
GetDiffFromHead returns the diff for a file comparing HEAD to working tree. This captures both staged and unstaged changes in a single diff.
func GetFileContentAtRef ¶ added in v0.81.0
GetFileContentAtRef retrieves a file's content at a given git ref (e.g., "HEAD", a commit hash). Returns empty string if the file doesn't exist at that ref.
func GetFileContentFromIndex ¶ added in v0.81.0
GetFileContentFromIndex retrieves a file's content from the git index (staged version). Returns empty string if the file is not in the index.
func GetFileDiffStats ¶
GetFileDiffStats returns the +/- counts for a single file.
func GetFolderDiff ¶
GetFolderDiff creates a concatenated diff for all files in an untracked folder. Each file gets a header with its path, followed by its content as additions.
func GetFullDiff ¶
GetFullDiff returns the diff for all changes.
func GetNewFileDiff ¶
GetNewFileDiff creates a diff-like view for an untracked file. Shows file content as all additions (new file).
func GetRemoteName ¶
GetRemoteName returns the primary remote name (usually "origin"). Returns empty string if no remotes are configured.
func GetRemoteURL ¶
GetRemoteURL returns the URL for the primary remote (origin).
func GetWorkingTreeFileContent ¶ added in v0.81.0
GetWorkingTreeFileContent reads a file from the working tree.
func IsConflictError ¶
IsConflictError checks if a RemoteError indicates merge/rebase conflicts.
func IsRebaseInProgress ¶
IsRebaseInProgress checks if a rebase is currently in progress.
func MinimapScrollTarget ¶ added in v0.81.0
MinimapScrollTarget converts a minimap click Y position to a scroll target. clickRow is the 0-based row within the minimap area.
func ParsePushOutput ¶
ParsePushOutput extracts useful information from git push output. Returns a human-readable summary.
func PopulatePushStatus ¶
func PopulatePushStatus(commits []*Commit, pushStatus *PushStatus)
PopulatePushStatus updates the Pushed field for a list of commits based on the provided push status.
func RelativeTime ¶
RelativeTime returns a human-readable relative time string.
func RenderFileHeader ¶
RenderFileHeader renders a file header bar for the diff.
func RenderFullFileSideBySide ¶ added in v0.81.0
func RenderFullFileSideBySide(fullDiff *FullFileDiff, width, startLine, maxLines, horizontalOffset int, highlighter *SyntaxHighlighter, wrapEnabled bool) string
RenderFullFileSideBySide renders a full-file diff in side-by-side format. Unlike RenderSideBySide which only shows hunks, this shows the entire file with changes highlighted in context (like VS Code's diff viewer).
func RenderLineDiff ¶
func RenderLineDiff(diff *ParsedDiff, width, startLine, maxLines, horizontalOffset int, highlighter *SyntaxHighlighter, wrapEnabled bool) string
RenderLineDiff renders a parsed diff in unified line-by-line format with line numbers. horizontalOffset scrolls the content horizontally (0 = no scroll). highlighter is optional - if nil, no syntax highlighting is applied. wrapEnabled wraps long lines instead of truncating them.
func RenderMinimap ¶ added in v0.81.0
func RenderMinimap(fullDiff *FullFileDiff, scrollPos, visibleLines, height int) string
RenderMinimap produces a minimap for the full-file diff view.
Each terminal row encodes two file-line slots via the half-block character ▀ (foreground = top slot, background = bottom slot), giving 2× vertical resolution.
scrollPos is the first visible line index, visibleLines is the viewport height in file lines, and height is the minimap height in terminal rows.
The output ends with a trailing newline on each row (matching the diff renderer format) so that lipgloss.JoinHorizontal aligns correctly.
func RenderMultiFileDiff ¶
func RenderMultiFileDiff(mfd *MultiFileDiff, mode DiffViewMode, width, startLine, maxLines, horizontalOffset int, wrapEnabled bool) string
RenderMultiFileDiff renders a multi-file diff with file headers. Returns the rendered content and updates file position info.
func RenderSideBySide ¶
func RenderSideBySide(diff *ParsedDiff, width, startLine, maxLines, horizontalOffset int, highlighter *SyntaxHighlighter, wrapEnabled bool) string
RenderSideBySide renders a parsed diff in side-by-side format. highlighter is optional - if nil, no syntax highlighting is applied. wrapEnabled wraps long lines instead of truncating them.
func StashApply ¶
StashApply applies a stash without removing it.
Types ¶
type AmendMessageLoadedMsg ¶ added in v0.93.0
func (AmendMessageLoadedMsg) GetEpoch ¶ added in v0.93.0
func (m AmendMessageLoadedMsg) GetEpoch() uint64
type Branch ¶
type Branch struct {
Name string // Branch name
IsCurrent bool // True if this is the current branch
IsRemote bool // True if this is a remote tracking branch
Upstream string // Upstream branch name (if set)
Ahead int // Commits ahead of upstream
Behind int // Commits behind upstream
LastCommit string // Short hash of last commit
}
Branch represents a git branch.
func GetBranches ¶
GetBranches retrieves the list of local branches.
func (*Branch) FormatTrackingInfo ¶
FormatTrackingInfo formats the ahead/behind info for display.
type BranchError ¶
BranchError wraps a git branch error with its output.
func (*BranchError) Error ¶
func (e *BranchError) Error() string
type BranchErrorMsg ¶
BranchErrorMsg is sent when a branch operation fails.
func (BranchErrorMsg) GetEpoch ¶ added in v0.93.0
func (m BranchErrorMsg) GetEpoch() uint64
type BranchListLoadedMsg ¶
type BranchListLoadedMsg struct {
Epoch uint64 // Epoch when request was issued (for stale detection)
Branches []*Branch
}
BranchListLoadedMsg is sent when branch list is loaded.
func (BranchListLoadedMsg) GetEpoch ¶
func (m BranchListLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type BranchSwitchSuccessMsg ¶
BranchSwitchSuccessMsg is sent when branch switch succeeds.
func (BranchSwitchSuccessMsg) GetEpoch ¶ added in v0.93.0
func (m BranchSwitchSuccessMsg) GetEpoch() uint64
type Commit ¶
type Commit struct {
Hash string
ShortHash string
Author string
AuthorEmail string
Date time.Time
Subject string
Body string
Files []CommitFile
Stats CommitStats
Pushed bool // Whether this commit has been pushed to upstream
ParentHashes []string // Parent commit hashes (empty for root commits)
IsMerge bool // True if commit has multiple parents
}
Commit represents a git commit.
func GetCommitDetail ¶
GetCommitDetail fetches full commit info including file list.
func GetCommitHistory ¶
GetCommitHistory fetches recent commits.
func GetCommitHistoryFiltered ¶
func GetCommitHistoryFiltered(workDir string, opts HistoryFilterOpts) ([]*Commit, error)
GetCommitHistoryFiltered fetches commits with filters applied.
type CommitCountLoadedMsg ¶ added in v0.96.0
CommitCountLoadedMsg is sent when total repo commit count is available. Loaded independently of the commit page so a slow rev-list never delays the infinite-scroll list. RequestID matches history single-flight so an older in-flight count cannot overwrite a newer one.
func (CommitCountLoadedMsg) GetEpoch ¶ added in v0.96.0
func (m CommitCountLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type CommitError ¶
CommitError wraps a git commit error with its output.
func (*CommitError) Error ¶
func (e *CommitError) Error() string
type CommitErrorMsg ¶
func (CommitErrorMsg) GetEpoch ¶ added in v0.93.0
func (m CommitErrorMsg) GetEpoch() uint64
type CommitFile ¶
type CommitFile struct {
Path string
OldPath string // For renames
Status FileStatus
Additions int
Deletions int
}
CommitFile represents a file changed in a commit.
type CommitPreviewLoadedMsg ¶
type CommitPreviewLoadedMsg struct {
Epoch uint64 // Epoch when request was issued (for stale detection)
RequestID uint64
Commit *Commit
Err error
}
CommitPreviewLoadedMsg is sent when commit preview is loaded.
func (CommitPreviewLoadedMsg) GetEpoch ¶
func (m CommitPreviewLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type CommitStats ¶
CommitStats holds aggregate commit statistics.
type CommitStatsLoadedMsg ¶
type CommitStatsLoadedMsg struct {
Epoch uint64 // Epoch when request was issued (for stale detection)
Hash string
Stats CommitStats
}
CommitStatsLoadedMsg is sent when commit stats are loaded.
func (CommitStatsLoadedMsg) GetEpoch ¶
func (m CommitStatsLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type CommitSuccessMsg ¶
func (CommitSuccessMsg) GetEpoch ¶ added in v0.93.0
func (m CommitSuccessMsg) GetEpoch() uint64
type DiffLine ¶
type DiffLine struct {
Type LineType
OldLineNo int // 0 means not applicable
NewLineNo int // 0 means not applicable
Content string
WordDiff []WordSegment
}
DiffLine represents a single line in a diff.
type DiffLoadedMsg ¶
type DiffLoadedMsg struct {
Epoch uint64 // Epoch when request was issued (for stale detection)
RequestID uint64
Content string // Rendered content (may be from delta)
Raw string // Raw diff for built-in rendering
Err error
}
func (DiffLoadedMsg) GetEpoch ¶
func (m DiffLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type DiffViewMode ¶
type DiffViewMode int
DiffViewMode specifies the diff rendering mode.
const ( DiffViewUnified DiffViewMode = iota // Line-by-line unified view DiffViewSideBySide // Side-by-side split view DiffViewFullFile // Full-file side-by-side view (like VS Code diff) )
type DiscardResultMsg ¶ added in v0.93.0
func (DiscardResultMsg) GetEpoch ¶ added in v0.93.0
func (m DiscardResultMsg) GetEpoch() uint64
type FetchErrorMsg ¶
FetchErrorMsg is sent when fetch fails.
func (FetchErrorMsg) GetEpoch ¶ added in v0.93.0
func (m FetchErrorMsg) GetEpoch() uint64
type FetchSuccessClearMsg ¶
type FetchSuccessClearMsg struct{}
FetchSuccessClearMsg is sent to clear the fetch success indicator.
type FetchSuccessMsg ¶
FetchSuccessMsg is sent when fetch succeeds.
func (FetchSuccessMsg) GetEpoch ¶ added in v0.93.0
func (m FetchSuccessMsg) GetEpoch() uint64
type FileDiffInfo ¶
type FileDiffInfo struct {
Diff *ParsedDiff
StartLine int // Line position where this file starts in rendered output
EndLine int // Line position where this file ends
Additions int // Number of added lines
Deletions int // Number of deleted lines
}
FileDiffInfo holds a parsed diff with rendering position info.
func (*FileDiffInfo) ChangeStats ¶
func (f *FileDiffInfo) ChangeStats() string
ChangeStats returns a formatted string like "+10/-5".
func (*FileDiffInfo) FileName ¶
func (f *FileDiffInfo) FileName() string
FileName returns the display filename (prefers NewFile, falls back to OldFile).
type FileEntry ¶
type FileEntry struct {
Path string
Status FileStatus
Staged bool
Unstaged bool
OldPath string // For renames
DiffStats DiffStats
IsExpanded bool
IsFolder bool // True if this represents an untracked folder
Children []*FileEntry // Files within this folder (when IsFolder is true)
}
FileEntry represents a single file or folder in the git status.
type FileStatus ¶
type FileStatus string
FileStatus represents the git status of a file.
const ( StatusModified FileStatus = "M" StatusAdded FileStatus = "A" StatusDeleted FileStatus = "D" StatusRenamed FileStatus = "R" StatusCopied FileStatus = "C" StatusUntracked FileStatus = "?" StatusIgnored FileStatus = "!" StatusUnmerged FileStatus = "U" )
type FileTree ¶
type FileTree struct {
Staged []*FileEntry
Modified []*FileEntry
Untracked []*FileEntry
// contains filtered or unexported fields
}
FileTree groups files by status category.
func LoadFileTree ¶ added in v0.93.0
LoadFileTree builds a complete status snapshot without mutating a tree that may be visible to the Bubble Tea event loop.
func LoadFileTreeContext ¶ added in v0.94.0
LoadFileTreeContext builds a complete status snapshot and cancels all Git subprocesses when ctx is cancelled.
func NewFileTree ¶
NewFileTree creates an empty file tree for the given work directory.
func (*FileTree) AllEntries ¶
AllEntries returns all entries in display order. Folder entries are included, and if expanded, their children follow.
func (*FileTree) HasStagedFiles ¶
HasStagedFiles returns true if there are any staged files.
func (*FileTree) ModifiedStats ¶ added in v0.96.0
ModifiedStats returns total additions and deletions for modified (unstaged) files.
func (*FileTree) RefreshContext ¶ added in v0.94.0
RefreshContext reloads Git status and observes ctx for every subprocess.
func (*FileTree) StageAllContext ¶ added in v0.94.0
StageAllContext stages all changes and observes ctx while Git runs.
func (*FileTree) StagedStats ¶
StagedStats returns total additions and deletions for staged files.
func (*FileTree) TotalCount ¶
TotalCount returns the total number of changed files.
func (*FileTree) UnstageAll ¶
UnstageAll unstages all staged files.
func (*FileTree) UnstageFile ¶
UnstageFile unstages a file.
type FilteredCommitsLoadedMsg ¶
type FilteredCommitsLoadedMsg struct {
Epoch uint64 // Epoch when request was issued (for stale detection)
Commits []*Commit
PushStatus *PushStatus
}
FilteredCommitsLoadedMsg is sent when filtered commits are fetched.
func (FilteredCommitsLoadedMsg) GetEpoch ¶
func (m FilteredCommitsLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type FocusPane ¶
type FocusPane int
FocusPane represents which pane is active in the three-pane view.
type FullFileDiff ¶ added in v0.81.0
type FullFileDiff struct {
Lines []FullFileLine // All aligned lines for rendering
OldFile string
NewFile string
}
FullFileDiff holds the complete aligned lines for a full-file side-by-side view.
func BuildFullFileDiff ¶ added in v0.81.0
func BuildFullFileDiff(oldContent, newContent string, parsed *ParsedDiff) *FullFileDiff
BuildFullFileDiff constructs a full-file diff from old/new file content and parsed hunks. It interleaves unchanged regions (context) with hunk changes to produce a complete side-by-side view of both files with changes highlighted.
func (*FullFileDiff) FullFileLineToHunkLine ¶ added in v0.81.0
func (ffd *FullFileDiff) FullFileLineToHunkLine(lineIdx int, parsed *ParsedDiff) int
FullFileLineToHunkLine maps a full-file line index to the closest hunk line index in the parsed diff. Returns the hunk line position suitable for unified/side-by-side scroll. This allows scroll position sync when toggling between full-file and hunk-only views.
func (*FullFileDiff) NextChange ¶ added in v0.81.0
func (ffd *FullFileDiff) NextChange(startLine int) int
NextChange returns the line index of the next change (add/remove) after startLine. Returns -1 if no more changes exist.
func (*FullFileDiff) PrevChange ¶ added in v0.81.0
func (ffd *FullFileDiff) PrevChange(startLine int) int
PrevChange returns the line index of the start of the previous change block before startLine. Returns -1 if no previous changes exist.
func (*FullFileDiff) TotalLines ¶ added in v0.81.0
func (ffd *FullFileDiff) TotalLines() int
TotalFullFileLines returns the total number of lines in a full-file diff.
type FullFileDiffLoadedMsg ¶ added in v0.81.0
type FullFileDiffLoadedMsg struct {
Epoch uint64
RequestID uint64
File string
OldContent string
NewContent string
Parsed *ParsedDiff
ForInline bool // True if this is for the inline diff pane, false for full-screen
}
FullFileDiffLoadedMsg is sent when full-file content is loaded for the full-file diff view.
func (FullFileDiffLoadedMsg) GetEpoch ¶ added in v0.81.0
func (m FullFileDiffLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type FullFileLine ¶ added in v0.81.0
type FullFileLine struct {
OldLineNo int // 0 means no line on the old side (added line)
NewLineNo int // 0 means no line on the new side (removed line)
OldText string // Text content on the old side
NewText string // Text content on the new side
Type LineType // LineContext, LineAdd, or LineRemove
}
FullFileLine represents a single line in the full-file diff view.
type GitHubInfo ¶
GitHubInfo holds parsed GitHub repository information.
func ParseGitHubInfo ¶
func ParseGitHubInfo(remoteURL string) *GitHubInfo
ParseGitHubInfo extracts owner/repo from a GitHub remote URL. Returns nil if not a GitHub URL.
type GraphColumn ¶
type GraphColumn struct {
CommitHash string // Hash of commit this column is tracking toward
Active bool // Whether this column is currently in use
}
GraphColumn tracks the state of one branch line in the commit graph.
type GraphLine ¶
type GraphLine struct {
Chars []rune // The ASCII characters for this line (*, |, \, /, etc.)
Width int // Total visual width of this line
}
GraphLine holds the ASCII characters for one commit row.
func ComputeGraphForCommits ¶
ComputeGraphForCommits generates GraphLine for each commit in order.
type GraphState ¶
type GraphState struct {
// contains filtered or unexported fields
}
GraphState maintains state while computing graph for commit list.
func NewGraphState ¶
func NewGraphState() *GraphState
NewGraphState creates a new graph computation state.
func (*GraphState) ComputeGraphLine ¶
func (g *GraphState) ComputeGraphLine(commit *Commit) GraphLine
ComputeGraphLine generates the GraphLine for a commit given current state. Updates state for the next commit.
type HighlightSegment ¶
HighlightSegment represents a segment of highlighted text.
type HistoryFilterOpts ¶
type HistoryFilterOpts struct {
Author string // Filter by author (--author)
Path string // Filter by file path (-- <path>)
Limit int
Skip int
}
HistoryFilterOpts holds options for filtered commit queries.
type HistorySearchState ¶
type HistorySearchState struct {
Query string
Matches []*Commit // Commits matching the query
Cursor int // Index in matches for n/N navigation
Committed bool // True after Enter (enables n/N)
// Search options
UseRegex bool
CaseSensitive bool
}
HistorySearchState holds state for commit history search.
func NewHistorySearchState ¶
func NewHistorySearchState() *HistorySearchState
NewHistorySearchState creates a new search state.
func (*HistorySearchState) Reset ¶
func (s *HistorySearchState) Reset()
Reset clears the search state.
type Hunk ¶
type Hunk struct {
OldStart int
OldCount int
NewStart int
NewCount int
Header string
Lines []DiffLine
// contains filtered or unexported fields
}
Hunk represents a diff hunk.
type InlineDiffLoadedMsg ¶
type InlineDiffLoadedMsg struct {
Epoch uint64 // Epoch when request was issued (for stale detection)
RequestID uint64
File string
Raw string
Parsed *ParsedDiff
}
InlineDiffLoadedMsg is sent when an inline diff finishes loading.
func (InlineDiffLoadedMsg) GetEpoch ¶
func (m InlineDiffLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type MoreCommitsLoadedMsg ¶
type MoreCommitsLoadedMsg struct {
Epoch uint64 // Epoch when request was issued (for stale detection)
Commits []*Commit
PushStatus *PushStatus
}
MoreCommitsLoadedMsg is sent when additional commits are fetched for infinite scroll.
func (MoreCommitsLoadedMsg) GetEpoch ¶
func (m MoreCommitsLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type MultiFileDiff ¶
type MultiFileDiff struct {
Files []FileDiffInfo
}
MultiFileDiff holds multiple file diffs with navigation info.
func ParseMultiFileDiff ¶
func ParseMultiFileDiff(diff string) *MultiFileDiff
ParseMultiFileDiff parses a git diff output containing multiple files.
func (*MultiFileDiff) FileAtLine ¶
func (mfd *MultiFileDiff) FileAtLine(line int) int
FileAtLine returns the file index at the given line position, or -1 if none.
func (*MultiFileDiff) FileCount ¶
func (mfd *MultiFileDiff) FileCount() int
FileCount returns the number of files in the diff.
func (*MultiFileDiff) TotalLines ¶
func (mfd *MultiFileDiff) TotalLines() int
TotalLines returns the total number of rendered lines for a multi-file diff.
type ParsedDiff ¶
type ParsedDiff struct {
OldFile string
NewFile string
Binary bool
Hunks []Hunk
// contains filtered or unexported fields
}
ParsedDiff represents a fully parsed diff.
func ParseUnifiedDiff ¶
func ParseUnifiedDiff(diff string) (*ParsedDiff, error)
ParseUnifiedDiff parses a unified diff format string.
func (*ParsedDiff) MaxContentWidth ¶ added in v0.97.0
func (p *ParsedDiff) MaxContentWidth() int
MaxContentWidth returns the widest line content in the diff, memoized.
func (*ParsedDiff) MaxLineNumber ¶
func (p *ParsedDiff) MaxLineNumber() int
MaxLineNumber returns the maximum line number in the diff.
func (*ParsedDiff) TotalLines ¶
func (p *ParsedDiff) TotalLines() int
TotalLines returns the total number of content lines in the diff.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements the git status plugin.
func (*Plugin) BlocksGlobalKeys ¶ added in v0.96.0
BlocksGlobalKeys reports whether a plugin-owned overlay has keyboard focus.
func (*Plugin) ConsumesTextInput ¶
ConsumesTextInput reports whether the plugin is currently in a mode where printable keys should be treated as text input.
func (*Plugin) Diagnostics ¶
func (p *Plugin) Diagnostics() []plugin.Diagnostic
Diagnostics returns plugin health info.
func (*Plugin) FocusContext ¶
FocusContext returns the current focus context.
func (*Plugin) WheelAtBoundary ¶ added in v1.0.0
func (p *Plugin) WheelAtBoundary(msg tea.MouseWheelMsg) bool
WheelAtBoundary implements plugin.WheelBoundaryConsumer for Git's status, full-screen diff, and modal surfaces. Modal view modes are answered by the modal that owns mouse input, in the same precedence Update uses, and never by the panes underneath. The history-search and path-filter overlays do not intercept the wheel, so the status panes answer while they are open.
type PullAbortedMsg ¶
type PullAbortedMsg struct{ Epoch uint64 }
PullAbortedMsg is sent when a conflicted pull is aborted.
func (PullAbortedMsg) GetEpoch ¶ added in v0.93.0
func (m PullAbortedMsg) GetEpoch() uint64
type PullErrorMsg ¶
type PullErrorMsg struct {
Epoch uint64
Err error
Strategy string // "merge", "rebase", "ff-only", "autostash"
}
PullErrorMsg is sent when pull fails.
func (PullErrorMsg) GetEpoch ¶ added in v0.93.0
func (m PullErrorMsg) GetEpoch() uint64
type PullSuccessClearMsg ¶
type PullSuccessClearMsg struct{}
PullSuccessClearMsg is sent to clear the pull success indicator.
type PullSuccessMsg ¶
PullSuccessMsg is sent when pull succeeds.
func (PullSuccessMsg) GetEpoch ¶ added in v0.93.0
func (m PullSuccessMsg) GetEpoch() uint64
type PushErrorMsg ¶
PushErrorMsg is sent when a push fails.
func (PushErrorMsg) GetEpoch ¶ added in v0.93.0
func (m PushErrorMsg) GetEpoch() uint64
type PushStatus ¶
type PushStatus struct {
HasUpstream bool // Whether an upstream branch is configured
UpstreamBranch string // Name of upstream branch (e.g., "origin/main")
Ahead int // Commits ahead of upstream
Behind int // Commits behind upstream
UnpushedHashes []string // Hashes of unpushed commits
DetachedHead bool // Whether HEAD is detached
CurrentBranch string // Current branch name (empty if detached)
}
PushStatus represents the push state of the current branch.
func GetPushStatus ¶
func GetPushStatus(workDir string) *PushStatus
GetPushStatus retrieves the push status for the current branch. Returns a PushStatus struct with information about ahead/behind counts, unpushed commits, and upstream configuration. Always returns a valid PushStatus (may be minimal if operations fail).
func (*PushStatus) CanPush ¶
func (ps *PushStatus) CanPush() bool
CanPush checks if there are commits that can be pushed.
func (*PushStatus) FormatAheadBehind ¶
func (ps *PushStatus) FormatAheadBehind() string
FormatAheadBehind returns a formatted string showing ahead/behind status. Examples: "↑2", "↓1", "↑2 ↓1", "" (when synced)
func (*PushStatus) IsCommitPushed ¶
func (ps *PushStatus) IsCommitPushed(hash string) bool
IsCommitPushed checks if a commit hash is pushed to the upstream. Returns true if the commit is in the upstream branch. Hash can be either full (40 chars) or short (7+ chars).
func (*PushStatus) NeedsForce ¶
func (ps *PushStatus) NeedsForce() bool
NeedsForce checks if push would require force (when behind upstream).
type PushStatusLoadedMsg ¶
type PushStatusLoadedMsg struct {
Status *PushStatus
}
PushStatusLoadedMsg is sent when push status is loaded.
type PushSuccessClearMsg ¶
type PushSuccessClearMsg struct{}
PushSuccessClearMsg is sent to clear the push success indicator.
type PushSuccessMsg ¶
PushSuccessMsg is sent when a push completes successfully.
func (PushSuccessMsg) GetEpoch ¶ added in v0.93.0
func (m PushSuccessMsg) GetEpoch() uint64
type RecentCommitsLoadedMsg ¶
type RecentCommitsLoadedMsg struct {
Epoch uint64 // Epoch when request was issued (for stale detection)
RequestID uint64
Commits []*Commit
PushStatus *PushStatus
Err error
}
RecentCommitsLoadedMsg is sent when recent commits are loaded for sidebar.
func (RecentCommitsLoadedMsg) GetEpoch ¶
func (m RecentCommitsLoadedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type RemoteError ¶
RemoteError wraps a git remote operation error with its output.
func (*RemoteError) Error ¶
func (e *RemoteError) Error() string
type RepoDetectedMsg ¶
RepoDetectedMsg is sent after probing for a repository in the current workdir.
func (RepoDetectedMsg) GetEpoch ¶
func (m RepoDetectedMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type RepoInitDoneMsg ¶
RepoInitDoneMsg is sent after attempting to run git init. Root is set on successful repository creation. Err is optional and may contain non-fatal warnings (for example, .gitignore update failures).
func (RepoInitDoneMsg) GetEpoch ¶
func (m RepoInitDoneMsg) GetEpoch() uint64
GetEpoch implements plugin.EpochMessage.
type SideBySideClipInfo ¶
type SideBySideClipInfo struct {
HasMoreLeft bool // True if scrolled right (horizOffset > 0)
HasMoreRight bool // True if content extends beyond visible width
MaxContentWidth int // Maximum width of any line in the diff
}
SideBySideClipInfo contains information about horizontal clipping state.
func GetSideBySideClipInfo ¶
func GetSideBySideClipInfo(diff *ParsedDiff, contentWidth, horizontalOffset int) SideBySideClipInfo
GetSideBySideClipInfo calculates clipping info for a side-by-side diff. contentWidth is the width available for each side's content (after line numbers).
type Stash ¶
type Stash struct {
Index int // stash index (0 = most recent)
Ref string // stash@{0}, stash@{1}, etc.
Branch string // Branch the stash was created on
Message string // Stash message
}
Stash represents a single stash entry.
type StashError ¶
StashError wraps a git stash error with its output.
func (*StashError) Error ¶
func (e *StashError) Error() string
type StashErrorMsg ¶
type StashErrorMsg struct {
Err error
}
StashErrorMsg is sent when stash operations fail.
type StashList ¶
type StashList struct {
Stashes []*Stash
}
StashList represents the list of stashes.
func GetStashList ¶
GetStashList retrieves the list of stashes.
type StashPopConfirmMsg ¶
type StashPopConfirmMsg struct {
Stash *Stash
}
StashPopConfirmMsg is sent when the stash pop confirm modal should be shown.
type StashResultMsg ¶
type StashResultMsg struct {
Epoch uint64
Operation string // "push", "pop", or "apply"
Ref string // stash ref for display (e.g. "stash@{0}")
Err error
}
StashResultMsg is sent when a stash operation completes.
func (StashResultMsg) GetEpoch ¶ added in v0.93.0
func (m StashResultMsg) GetEpoch() uint64
type StatusSnapshotLoadedMsg ¶ added in v0.93.0
Message types
func (StatusSnapshotLoadedMsg) GetEpoch ¶ added in v0.93.0
func (m StatusSnapshotLoadedMsg) GetEpoch() uint64
type SyntaxHighlighter ¶
type SyntaxHighlighter struct {
// contains filtered or unexported fields
}
SyntaxHighlighter provides syntax highlighting for diff content using Chroma.
func NewSyntaxHighlighter ¶
func NewSyntaxHighlighter(filename string) *SyntaxHighlighter
NewSyntaxHighlighter creates a highlighter for the given filename. Returns nil if no lexer is available for the file type.
func (*SyntaxHighlighter) Highlight ¶
func (h *SyntaxHighlighter) Highlight(line string) []HighlightSegment
Highlight tokenizes and highlights a line of code. Returns segments with lipgloss styles applied.
func (*SyntaxHighlighter) HighlightLine ¶
func (h *SyntaxHighlighter) HighlightLine(content string) []HighlightSegment
HighlightLine highlights a single line of code, returning styled segments.
type ViewMode ¶
type ViewMode int
ViewMode represents the current view state.
const ( ViewModeStatus ViewMode = iota // Current file list (three-pane layout) ViewModeDiff // Full-screen diff view ViewModeCommit // Commit message editor ViewModePushMenu // Push options popup menu ViewModePullMenu // Pull options popup menu ViewModeConfirmDiscard // Confirm discard changes modal ViewModeBranchPicker // Branch selection modal ViewModeConfirmStashPop // Confirm stash pop modal ViewModePullConflict // Pull conflict resolution modal ViewModeError // Generic error modal for git operation failures )
type WatchEvent ¶ added in v0.93.0
type WatchEvent struct{ History bool }
type WatchEventMsg ¶
func (WatchEventMsg) GetEpoch ¶ added in v0.93.0
func (m WatchEventMsg) GetEpoch() uint64
type WatchStartFailedMsg ¶ added in v0.93.0
func (WatchStartFailedMsg) GetEpoch ¶ added in v0.93.0
func (m WatchStartFailedMsg) GetEpoch() uint64
type WatchStartedMsg ¶
func (WatchStartedMsg) GetEpoch ¶ added in v0.93.0
func (m WatchStartedMsg) GetEpoch() uint64
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors Git's administrative files. These are not necessarily below <worktree>/.git: linked worktrees keep HEAD and index in a per-worktree admin directory while refs live in the common repository directory.
func NewWatcher ¶
func (*Watcher) Events ¶
func (w *Watcher) Events() <-chan WatchEvent
type WordSegment ¶
WordSegment represents a segment of text with word-level diff highlighting.
Source Files
¶
- branch.go
- branch_picker.go
- clipboard.go
- commit_view.go
- confirm_discard.go
- confirm_stash_pop.go
- data_loaders.go
- diff.go
- diff_parser.go
- diff_renderer.go
- doc.go
- error_modal.go
- git_operations.go
- gitcmd.go
- github.go
- graph.go
- history.go
- history_search.go
- minimap.go
- mouse.go
- no_repo.go
- plugin.go
- preview_selection.go
- pull_menu.go
- push.go
- push_menu.go
- remote.go
- scroll_layout.go
- sidebar_view.go
- stash.go
- syntax_highlight.go
- tree.go
- trunc_cache.go
- update_handlers.go
- view.go
- watcher.go
- write_operation.go