Documentation
¶
Overview ¶
Package git provides git repository operations using go-git library.
Index ¶
- type Repo
- func (r *Repo) Add(path string) error
- func (r *Repo) BranchExists(name string) bool
- func (r *Repo) CheckoutBranch(name string) error
- func (r *Repo) Commit(msg string) error
- func (r *Repo) CreateBranch(name string) error
- func (r *Repo) CurrentBranch() (string, error)
- func (r *Repo) FileHasChanges(filePath string) (bool, error)
- func (r *Repo) HasChangesOtherThan(filePath string) (bool, error)
- func (r *Repo) HasCommits() (bool, error)
- func (r *Repo) IsDirty() (bool, error)
- func (r *Repo) IsIgnored(path string) (bool, error)
- func (r *Repo) MoveFile(src, dst string) error
- func (r *Repo) Root() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo provides git operations using go-git.
func Open ¶
Open opens a git repository at the given path. Supports both regular repositories and git worktrees.
func (*Repo) Add ¶
Add stages a file for commit. Path can be absolute or relative to the repository root.
func (*Repo) BranchExists ¶
BranchExists checks if a branch with the given name exists.
func (*Repo) CheckoutBranch ¶
CheckoutBranch switches to an existing branch.
func (*Repo) Commit ¶
Commit creates a commit with the given message. Returns error if no changes are staged.
func (*Repo) CreateBranch ¶
CreateBranch creates a new branch and switches to it. Returns error if branch already exists to prevent data loss.
func (*Repo) CurrentBranch ¶
CurrentBranch returns the name of the current branch, or empty string for detached HEAD state.
func (*Repo) FileHasChanges ¶ added in v0.4.0
FileHasChanges returns true if the given file has uncommitted changes. this includes untracked, modified, deleted, or staged states.
func (*Repo) HasChangesOtherThan ¶ added in v0.4.0
HasChangesOtherThan returns true if there are uncommitted changes to files other than the given file. this includes modified/deleted tracked files, staged changes, and untracked files (excluding gitignored).
func (*Repo) HasCommits ¶ added in v0.4.0
HasCommits returns true if the repository has at least one commit.
func (*Repo) IsDirty ¶ added in v0.2.1
IsDirty returns true if the worktree has uncommitted changes (staged or modified tracked files).
func (*Repo) IsIgnored ¶
IsIgnored checks if a path is ignored by gitignore rules. Checks local .gitignore files, global gitignore (from core.excludesfile or default XDG location ~/.config/git/ignore), and system gitignore (/etc/gitconfig). Returns false, nil if no gitignore rules exist.