gitstatus

package
v0.74.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package gitstatus implements the git status plugin with staging/unstaging, diff viewing, commit history, branch management, and conflict resolution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortMerge

func AbortMerge(workDir string) error

AbortMerge runs git merge --abort.

func AbortRebase

func AbortRebase(workDir string) error

AbortRebase runs git rebase --abort.

func BuildCommitURL

func BuildCommitURL(info *GitHubInfo, hash string) string

BuildCommitURL constructs a GitHub commit URL.

func CheckoutBranch

func CheckoutBranch(workDir, branchName string) error

CheckoutBranch switches to a branch.

func CreateBranch

func CreateBranch(workDir, branchName string) error

CreateBranch creates a new branch from HEAD.

func DeleteBranch

func DeleteBranch(workDir, branchName string) error

DeleteBranch deletes a branch.

func DiscardModified

func DiscardModified(workDir, path string) error

DiscardModified discards unstaged changes to a modified file.

func DiscardStaged

func DiscardStaged(workDir, path string) error

DiscardStaged discards staged changes to a file (unstages and restores).

func DiscardUntracked

func DiscardUntracked(workDir, path string) error

DiscardUntracked removes an untracked file.

func ExecuteAmend

func ExecuteAmend(workDir, message string) (string, error)

ExecuteAmend executes a git commit --amend with the given message.

func ExecuteCommit

func ExecuteCommit(workDir, message string) (string, error)

ExecuteCommit executes a git commit with the given message. Returns the commit hash on success or an error with git output on failure.

func ExecuteFetch

func ExecuteFetch(workDir string) (string, error)

ExecuteFetch runs git fetch.

func ExecutePull

func ExecutePull(workDir string) (string, error)

ExecutePull runs git pull.

func ExecutePullAutostash

func ExecutePullAutostash(workDir string) (string, error)

ExecutePullAutostash runs git pull --rebase --autostash.

func ExecutePullFFOnly

func ExecutePullFFOnly(workDir string) (string, error)

ExecutePullFFOnly runs git pull --ff-only.

func ExecutePullRebase

func ExecutePullRebase(workDir string) (string, error)

ExecutePullRebase runs git pull --rebase.

func ExecutePush

func ExecutePush(workDir string, force bool) (string, error)

ExecutePush performs a git push operation. Returns the output from git and any error encountered.

func ExecutePushForce

func ExecutePushForce(workDir string) (string, error)

ExecutePushForce performs a force push with lease. Returns the output from git and any error encountered.

func ExecutePushSetUpstream

func ExecutePushSetUpstream(workDir string) (string, error)

ExecutePushSetUpstream performs a push with upstream tracking. Returns the output from git and any error encountered.

func ForceDeleteBranch

func ForceDeleteBranch(workDir, branchName string) error

ForceDeleteBranch force-deletes a branch.

func GetCommitDiff

func GetCommitDiff(workDir, hash, path string, parentHash string) (string, error)

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

func GetCommitFullDiff(workDir, hash string) (string, error)

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

func GetConflictedFiles(workDir string) []string

GetConflictedFiles returns a list of files with merge conflicts.

func GetDiff

func GetDiff(workDir, path string, staged bool) (string, error)

GetDiff returns the diff for a file.

func GetFileDiffStats

func GetFileDiffStats(workDir, path string, staged bool) (int, int, error)

GetFileDiffStats returns the +/- counts for a single file.

func GetFolderDiff

func GetFolderDiff(workDir string, files []*FileEntry) (string, error)

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

func GetFullDiff(workDir string, staged bool) (string, error)

GetFullDiff returns the diff for all changes.

func GetNewFileDiff

func GetNewFileDiff(workDir, path string) (string, error)

GetNewFileDiff creates a diff-like view for an untracked file. Shows file content as all additions (new file).

func GetRemoteName

func GetRemoteName(workDir string) string

GetRemoteName returns the primary remote name (usually "origin"). Returns empty string if no remotes are configured.

func GetRemoteURL

func GetRemoteURL(workDir string) string

GetRemoteURL returns the URL for the primary remote (origin).

func HasRemote

func HasRemote(workDir string) bool

HasRemote checks if any remote is configured for the repository.

func IsConflictError

func IsConflictError(err error) bool

IsConflictError checks if a RemoteError indicates merge/rebase conflicts.

func IsRebaseInProgress

func IsRebaseInProgress(workDir string) bool

IsRebaseInProgress checks if a rebase is currently in progress.

func ParsePushOutput

func ParsePushOutput(output string) string

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

func RelativeTime(t time.Time) string

RelativeTime returns a human-readable relative time string.

func RenderFileHeader

func RenderFileHeader(filename, stats string, width int) string

RenderFileHeader renders a file header bar for the diff.

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 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

func StashApply(workDir, ref string) error

StashApply applies a stash without removing it.

func StashDrop

func StashDrop(workDir, ref string) error

StashDrop removes a stash.

func StashPop

func StashPop(workDir string) error

StashPop pops the most recent stash.

func StashPopRef

func StashPopRef(workDir, ref string) error

StashPopRef pops a specific stash by reference.

func StashPush

func StashPush(workDir string) error

StashPush creates a new stash with all changes.

func StashPushIncludeUntracked

func StashPushIncludeUntracked(workDir string) error

StashPushIncludeUntracked creates a stash including untracked files.

func StashPushWithMessage

func StashPushWithMessage(workDir, message string) error

StashPushWithMessage creates a new stash with a custom message.

Types

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

func GetBranches(workDir string) ([]*Branch, error)

GetBranches retrieves the list of local branches.

func (*Branch) FormatTrackingInfo

func (b *Branch) FormatTrackingInfo() string

FormatTrackingInfo formats the ahead/behind info for display.

type BranchError

type BranchError struct {
	Output string
	Err    error
}

BranchError wraps a git branch error with its output.

func (*BranchError) Error

func (e *BranchError) Error() string

type BranchErrorMsg

type BranchErrorMsg struct {
	Err error
}

BranchErrorMsg is sent when a branch operation fails.

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

type BranchSwitchSuccessMsg struct {
	Branch string
}

BranchSwitchSuccessMsg is sent when branch switch succeeds.

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

func GetCommitDetail(workDir, hash string) (*Commit, error)

GetCommitDetail fetches full commit info including file list.

func GetCommitHistory

func GetCommitHistory(workDir string, limit int) ([]*Commit, error)

GetCommitHistory fetches recent commits.

func GetCommitHistoryFiltered

func GetCommitHistoryFiltered(workDir string, opts HistoryFilterOpts) ([]*Commit, error)

GetCommitHistoryFiltered fetches commits with filters applied.

func GetCommitHistoryWithOffset

func GetCommitHistoryWithOffset(workDir string, limit, skip int) ([]*Commit, error)

GetCommitHistoryWithOffset fetches commits starting from skip, up to limit. Uses git log --skip=N to paginate through history.

type CommitError

type CommitError struct {
	Output string
	Err    error
}

CommitError wraps a git commit error with its output.

func (*CommitError) Error

func (e *CommitError) Error() string

type CommitErrorMsg

type CommitErrorMsg struct {
	Err error
}

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)
	Commit *Commit
}

CommitPreviewLoadedMsg is sent when commit preview is loaded.

func (CommitPreviewLoadedMsg) GetEpoch

func (m CommitPreviewLoadedMsg) GetEpoch() uint64

GetEpoch implements plugin.EpochMessage.

type CommitStats

type CommitStats struct {
	FilesChanged int
	Additions    int
	Deletions    int
}

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

type CommitSuccessMsg struct {
	Hash    string
	Subject string
}

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)
	Content string // Rendered content (may be from delta)
	Raw     string // Raw diff for built-in rendering
}

func (DiffLoadedMsg) GetEpoch

func (m DiffLoadedMsg) GetEpoch() uint64

GetEpoch implements plugin.EpochMessage.

type DiffStats

type DiffStats struct {
	Additions int
	Deletions int
}

DiffStats holds addition/deletion counts.

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
)

type ErrorMsg

type ErrorMsg struct{ Err error }

type FetchErrorMsg

type FetchErrorMsg struct {
	Err error
}

FetchErrorMsg is sent when fetch fails.

type FetchSuccessClearMsg

type FetchSuccessClearMsg struct{}

FetchSuccessClearMsg is sent to clear the fetch success indicator.

type FetchSuccessMsg

type FetchSuccessMsg struct {
	Output string
}

FetchSuccessMsg is sent when fetch succeeds.

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 NewFileTree

func NewFileTree(workDir string) *FileTree

NewFileTree creates an empty file tree for the given work directory.

func (*FileTree) AllEntries

func (t *FileTree) AllEntries() []*FileEntry

AllEntries returns all entries in display order. Folder entries are included, and if expanded, their children follow.

func (*FileTree) HasStagedFiles

func (t *FileTree) HasStagedFiles() bool

HasStagedFiles returns true if there are any staged files.

func (*FileTree) Refresh

func (t *FileTree) Refresh() error

Refresh reloads the git status from disk.

func (*FileTree) StageAll

func (t *FileTree) StageAll() error

StageAll stages all modified and untracked files.

func (*FileTree) StageFile

func (t *FileTree) StageFile(path string) error

StageFile stages a file.

func (*FileTree) StagedStats

func (t *FileTree) StagedStats() (additions, deletions int)

StagedStats returns total additions and deletions for staged files.

func (*FileTree) Summary

func (t *FileTree) Summary() string

Summary returns a summary string like "2 staged, 3 modified".

func (*FileTree) TotalCount

func (t *FileTree) TotalCount() int

TotalCount returns the total number of changed files.

func (*FileTree) UnstageAll

func (t *FileTree) UnstageAll() error

UnstageAll unstages all staged files.

func (*FileTree) UnstageFile

func (t *FileTree) UnstageFile(path string) error

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.

const (
	PaneSidebar FocusPane = iota
	PaneDiff
)

type GitHubInfo

type GitHubInfo struct {
	Owner string
	Repo  string
}

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

func ComputeGraphForCommits(commits []*Commit) []GraphLine

ComputeGraphForCommits generates GraphLine for each commit in order.

func (*GraphLine) String

func (gl *GraphLine) String() string

GraphLineString returns the graph line as a plain string (for testing/debug).

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

type HighlightSegment struct {
	Text  string
	Style lipgloss.Style
}

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
}

Hunk represents a diff hunk.

type InlineDiffLoadedMsg

type InlineDiffLoadedMsg struct {
	Epoch  uint64 // Epoch when request was issued (for stale detection)
	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 LineType

type LineType int

LineType represents the type of a diff line.

const (
	LineContext LineType = iota
	LineAdd
	LineRemove
)

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
}

ParsedDiff represents a fully parsed diff.

func ParseUnifiedDiff

func ParseUnifiedDiff(diff string) (*ParsedDiff, error)

ParseUnifiedDiff parses a unified diff format string.

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 New

func New() *Plugin

New creates a new git status plugin.

func (*Plugin) Commands

func (p *Plugin) Commands() []plugin.Command

Commands returns the available commands.

func (*Plugin) ConsumesTextInput

func (p *Plugin) ConsumesTextInput() bool

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

func (p *Plugin) FocusContext() string

FocusContext returns the current focus context.

func (*Plugin) ID

func (p *Plugin) ID() string

ID returns the plugin identifier.

func (*Plugin) Icon

func (p *Plugin) Icon() string

Icon returns the plugin icon character.

func (*Plugin) Init

func (p *Plugin) Init(ctx *plugin.Context) error

Init initializes the plugin with context.

func (*Plugin) IsFocused

func (p *Plugin) IsFocused() bool

IsFocused returns whether the plugin is focused.

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns the plugin display name.

func (*Plugin) SetFocused

func (p *Plugin) SetFocused(f bool)

SetFocused sets the focus state.

func (*Plugin) Start

func (p *Plugin) Start() tea.Cmd

Start begins plugin operation.

func (*Plugin) Stop

func (p *Plugin) Stop()

Stop cleans up plugin resources.

func (*Plugin) Update

func (p *Plugin) Update(msg tea.Msg) (plugin.Plugin, tea.Cmd)

Update handles messages.

func (*Plugin) View

func (p *Plugin) View(width, height int) string

View renders the plugin.

type PullAbortedMsg

type PullAbortedMsg struct{}

PullAbortedMsg is sent when a conflicted pull is aborted.

type PullErrorMsg

type PullErrorMsg struct {
	Err      error
	Strategy string // "merge", "rebase", "ff-only", "autostash"
}

PullErrorMsg is sent when pull fails.

type PullSuccessClearMsg

type PullSuccessClearMsg struct{}

PullSuccessClearMsg is sent to clear the pull success indicator.

type PullSuccessMsg

type PullSuccessMsg struct {
	Output string
}

PullSuccessMsg is sent when pull succeeds.

type PushError

type PushError struct {
	Output string
	Err    error
}

PushError wraps a git push error with its output.

func (*PushError) Error

func (e *PushError) Error() string

type PushErrorMsg

type PushErrorMsg struct {
	Err error
}

PushErrorMsg is sent when a push fails.

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

type PushSuccessMsg struct {
	Output string
}

PushSuccessMsg is sent when a push completes successfully.

type RecentCommitsLoadedMsg

type RecentCommitsLoadedMsg struct {
	Epoch      uint64 // Epoch when request was issued (for stale detection)
	Commits    []*Commit
	PushStatus *PushStatus
}

RecentCommitsLoadedMsg is sent when recent commits are loaded for sidebar.

func (RecentCommitsLoadedMsg) GetEpoch

func (m RecentCommitsLoadedMsg) GetEpoch() uint64

GetEpoch implements plugin.EpochMessage.

type RefreshDoneMsg

type RefreshDoneMsg struct{}

Message types

type RemoteError

type RemoteError struct {
	Output string
	Err    error
}

RemoteError wraps a git remote operation error with its output.

func (*RemoteError) Error

func (e *RemoteError) Error() string

type RepoDetectedMsg

type RepoDetectedMsg struct {
	Epoch uint64
	Root  string
}

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

type RepoInitDoneMsg struct {
	Epoch uint64
	Root  string
	Err   error
}

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

type StashError struct {
	Output string
	Err    error
}

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

func GetStashList(workDir string) (*StashList, error)

GetStashList retrieves the list of stashes.

func (*StashList) Count

func (l *StashList) Count() int

Count returns the number 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 {
	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.

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 WatchEventMsg

type WatchEventMsg struct{}

type WatchStartedMsg

type WatchStartedMsg struct{ Watcher *Watcher }

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher monitors the .git directory for changes.

func NewWatcher

func NewWatcher(workDir string) (*Watcher, error)

NewWatcher creates a new git directory watcher.

func (*Watcher) Events

func (w *Watcher) Events() <-chan struct{}

Events returns the channel that receives change notifications.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop stops the watcher. The events channel is closed when run() exits.

type WordSegment

type WordSegment struct {
	Text     string
	IsChange bool
}

WordSegment represents a segment of text with word-level diff highlighting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL