Documentation
¶
Index ¶
- type Commit
- type FileChange
- type FileStatus
- type Repo
- func (r *Repo) BranchName() string
- func (r *Repo) ChangedFiles(staged bool, ref string) ([]FileChange, error)
- func (r *Repo) Commit(msg string) error
- func (r *Repo) CommitDiff(hash string) (string, error)
- func (r *Repo) CommitDiffFiles(hash string) ([]FileChange, error)
- func (r *Repo) DiffFile(path string, staged bool, ref string) (string, error)
- func (r *Repo) Dir() string
- func (r *Repo) HasCommits() bool
- func (r *Repo) Log(n int) ([]Commit, error)
- func (r *Repo) ReadFileContent(path string) (string, error)
- func (r *Repo) StageAll() error
- func (r *Repo) StageFile(path string) error
- func (r *Repo) StagedDiff() (string, error)
- func (r *Repo) UnstageFile(path string) error
- func (r *Repo) UntrackedFiles() ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileChange ¶
type FileChange struct {
Path string
OldPath string // non-empty for renames
Status FileStatus
Staged bool
}
FileChange represents a changed file in the working tree or index.
type FileStatus ¶
type FileStatus rune
FileStatus represents the type of change for a file.
const ( StatusModified FileStatus = 'M' StatusAdded FileStatus = 'A' StatusDeleted FileStatus = 'D' StatusRenamed FileStatus = 'R' StatusCopied FileStatus = 'C' StatusUntracked FileStatus = '?' )
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo wraps git operations for a repository.
func (*Repo) BranchName ¶
BranchName returns the current branch name, or short hash if detached.
func (*Repo) ChangedFiles ¶
func (r *Repo) ChangedFiles(staged bool, ref string) ([]FileChange, error)
ChangedFiles returns files changed in the working tree or index. If staged is true, only returns staged changes. If ref is non-empty, compares against that ref.
func (*Repo) CommitDiff ¶
CommitDiff returns the full diff for a commit. For the root commit (no parent), uses diff-tree against empty tree.
func (*Repo) CommitDiffFiles ¶
func (r *Repo) CommitDiffFiles(hash string) ([]FileChange, error)
CommitDiffFiles returns files changed in a commit.
func (*Repo) HasCommits ¶
HasCommits returns true if the repo has at least one commit.
func (*Repo) ReadFileContent ¶
ReadFileContent reads a file from the working tree.
func (*Repo) StagedDiff ¶
StagedDiff returns the full diff of staged changes.
func (*Repo) UnstageFile ¶
UnstageFile unstages a file.
func (*Repo) UntrackedFiles ¶
UntrackedFiles returns paths of untracked files.