git

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupWorktrees

func CleanupWorktrees() error

CleanupWorktrees removes all worktrees and their associated branches

func IsGitRepo

func IsGitRepo(path string) bool

IsGitRepo checks if the given path is within a git repository

Types

type DiffStats

type DiffStats struct {
	// Content is the full diff content
	Content string
	// Added is the number of added lines
	Added int
	// Removed is the number of removed lines
	Removed int
	// Error holds any error that occurred during diff computation
	// This allows propagating setup errors (like missing base commit) without breaking the flow
	Error error
}

DiffStats holds statistics about the changes in a diff

func (*DiffStats) IsEmpty

func (d *DiffStats) IsEmpty() bool

type GitWorktree

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

GitWorktree manages git worktree operations for a session

func NewGitWorktree

func NewGitWorktree(repoPath string, sessionName string) (tree *GitWorktree, branchname string, err error)

NewGitWorktree creates a new GitWorktree instance

func NewGitWorktreeFromStorage

func NewGitWorktreeFromStorage(repoPath string, worktreePath string, sessionName string, branchName string, baseCommitSHA string) *GitWorktree

func (*GitWorktree) Cleanup

func (g *GitWorktree) Cleanup() error

Cleanup removes the worktree and associated branch

func (*GitWorktree) CommitChanges

func (g *GitWorktree) CommitChanges(commitMessage string) error

CommitChanges commits changes locally without pushing to remote

func (*GitWorktree) CreatePR

func (g *GitWorktree) CreatePR(title, body, commitMsg string) error

CreatePR pushes changes and creates a pull request on GitHub.

func (*GitWorktree) Diff

func (g *GitWorktree) Diff() *DiffStats

Diff returns the git diff between the worktree and the base branch along with statistics

func (*GitWorktree) GeneratePRBody

func (g *GitWorktree) GeneratePRBody() (string, error)

GeneratePRBody assembles a markdown PR description from the branch's changed files, commit history, and diff stats.

func (*GitWorktree) GetBaseCommitSHA

func (g *GitWorktree) GetBaseCommitSHA() string

GetBaseCommitSHA returns the base commit SHA for the worktree

func (*GitWorktree) GetBranchName

func (g *GitWorktree) GetBranchName() string

GetBranchName returns the name of the branch associated with this worktree

func (*GitWorktree) GetRepoName

func (g *GitWorktree) GetRepoName() string

GetRepoName returns the name of the repository (last part of the repoPath).

func (*GitWorktree) GetRepoPath

func (g *GitWorktree) GetRepoPath() string

GetRepoPath returns the path to the repository

func (*GitWorktree) GetWorktreePath

func (g *GitWorktree) GetWorktreePath() string

GetWorktreePath returns the path to the worktree

func (*GitWorktree) IsBranchCheckedOut

func (g *GitWorktree) IsBranchCheckedOut() (bool, error)

IsBranchCheckedOut checks if the instance branch is currently checked out

func (*GitWorktree) IsDirty

func (g *GitWorktree) IsDirty() (bool, error)

IsDirty checks if the worktree has uncommitted changes

func (*GitWorktree) OpenBranchURL

func (g *GitWorktree) OpenBranchURL() error

OpenBranchURL opens the branch URL in the default browser

func (*GitWorktree) Prune

func (g *GitWorktree) Prune() error

Prune removes all working tree administrative files and directories

func (*GitWorktree) PushChanges

func (g *GitWorktree) PushChanges(commitMessage string, open bool) error

PushChanges commits and pushes changes in the worktree to the remote branch

func (*GitWorktree) Remove

func (g *GitWorktree) Remove() error

Remove removes the worktree but keeps the branch

func (*GitWorktree) Setup

func (g *GitWorktree) Setup() error

Setup creates a new worktree for the session

Jump to

Keyboard shortcuts

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