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) 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) 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. Returns false, nil if no .gitignore exists or cannot be read.