git

package
v0.0.0-...-6b1cd05 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const WatchInterval = 5 * time.Second

WatchInterval is the default polling interval for git changes.

Variables

This section is empty.

Functions

func ComputeDiff

func ComputeDiff(repoPath string) (string, error)

ComputeDiff runs `git diff` in the given directory and returns the output.

func ComputeDiffStat

func ComputeDiffStat(repoPath string) (string, error)

ComputeDiffStat runs `git diff --stat` and returns the summary.

func CurrentBranch

func CurrentBranch(repoPath string) (string, error)

CurrentBranch returns the current branch of a repository.

func DefaultBranch

func DefaultBranch(repoPath string) string

DefaultBranch detects the default branch for a repository. It checks origin/HEAD first, then falls back to checking if "main" or "master" exists.

func DiffCmd

func DiffCmd(sessionID, workDir string) tea.Cmd

DiffCmd computes the diff for a worktree and returns it as a message.

func GitStatus

func GitStatus(repoPath string) (string, error)

GitStatus returns the output of `git status --short`.

func IsGitRepo

func IsGitRepo(path string) bool

IsGitRepo returns true if the given path is inside a git repository.

func ListBranches

func ListBranches(repoPath string) ([]string, error)

ListBranches lists all branches (local and remote) for a repository.

func WatchCmd

func WatchCmd(sessionID string, interval time.Duration) tea.Cmd

WatchCmd returns a tea.Cmd that sends periodic WatchTickMsgs.

Types

type BranchChangedMsg

type BranchChangedMsg struct {
	SessionID string
	Branch    string
}

BranchChangedMsg is sent when a branch change is detected.

type DiffFile

type DiffFile struct {
	Path    string
	OldPath string // for renames
	Added   int
	Removed int
	Hunks   []DiffHunk
}

DiffFile represents a file in a diff.

func ParseUnifiedDiff

func ParseUnifiedDiff(diff string) []DiffFile

ParseUnifiedDiff parses a unified diff string into structured data.

type DiffHunk

type DiffHunk struct {
	Header string
	Lines  []DiffLine
}

DiffHunk represents a hunk in a diff.

type DiffLine

type DiffLine struct {
	Type    DiffLineType
	Content string
}

DiffLine represents a line in a diff hunk.

type DiffLineType

type DiffLineType int

DiffLineType indicates whether a line was added, removed, or unchanged.

const (
	DiffLineContext DiffLineType = iota
	DiffLineAdded
	DiffLineRemoved
)

type DiffUpdatedMsg

type DiffUpdatedMsg struct {
	SessionID string
	Diff      string
}

DiffUpdatedMsg is sent when the diff for a session has been updated.

type WatchTickMsg

type WatchTickMsg struct {
	SessionID string
}

WatchTickMsg is sent periodically to trigger diff updates.

type WorktreeCreatedMsg

type WorktreeCreatedMsg struct {
	ProjectName string
	FeatureName string
	Path        string
}

WorktreeCreatedMsg is sent when a worktree is successfully created.

type WorktreeManager

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

WorktreeManager handles git worktree operations.

func NewWorktreeManager

func NewWorktreeManager(baseDir string) *WorktreeManager

NewWorktreeManager creates a new worktree manager.

func (*WorktreeManager) Create

func (wm *WorktreeManager) Create(repoPath, projectName, featureName, baseBranch string) (string, error)

Create creates a new git worktree for a feature branch. repoPath is the path to the main repository. featureBranch is the name of the new branch to create. baseBranch is the branch to base the new branch on (e.g. "main").

func (*WorktreeManager) Exists

func (wm *WorktreeManager) Exists(projectName, featureName string) bool

Exists checks if a worktree exists for the given project/feature.

func (*WorktreeManager) List

func (wm *WorktreeManager) List(repoPath string) ([]string, error)

List lists all worktrees for a repository.

func (*WorktreeManager) Remove

func (wm *WorktreeManager) Remove(repoPath, projectName, featureName string) error

Remove removes a git worktree.

func (*WorktreeManager) WorktreePath

func (wm *WorktreeManager) WorktreePath(projectName, featureName string) string

WorktreePath returns the expected worktree path for a project/feature.

type WorktreeRemovedMsg

type WorktreeRemovedMsg struct {
	ProjectName string
	FeatureName string
}

WorktreeRemovedMsg is sent when a worktree is removed.

Jump to

Keyboard shortcuts

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