Documentation
¶
Overview ¶
Package git provides wrappers around git porcelain commands. All operations run git as a subprocess; no CGO, no libgit2.
Index ¶
- type AuthorStat
- type LogEntry
- type Repo
- func (r *Repo) BlameLines(file, ref string) (map[string]int64, error)
- func (r *Repo) Branches() ([]string, error)
- func (r *Repo) CommitAtDate(date string) (string, error)
- func (r *Repo) CurrentBranch() string
- func (r *Repo) HEAD() (string, error)
- func (r *Repo) IsClean() (bool, error)
- func (r *Repo) LastCommitTime() string
- func (r *Repo) ListFiles(ref string, excludePatterns []string) ([]string, error)
- func (r *Repo) Log(ref string, limit int, since, until string) ([]LogEntry, error)
- func (r *Repo) RevParse(ref string) (string, error)
- func (r *Repo) Shortlog(ref string) ([]AuthorStat, error)
- func (r *Repo) TreeSHA(ref string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorStat ¶
AuthorStat holds shortlog stats for one author.
type LogEntry ¶
type LogEntry struct {
Hash string
Author string
Email string
Date string // ISO 8601
Subject string
Added int64
Deleted int64
}
LogEntry is a single entry from git log --numstat.
type Repo ¶
type Repo struct {
Root string // absolute path to the repo root
GitDir string // path to .git dir or file
}
Repo represents a git repository.
func Discover ¶
Discover finds the git repository root starting from dir. Equivalent to `git rev-parse --show-toplevel`.
func (*Repo) BlameLines ¶
BlameLines runs git blame --porcelain for a file and returns per-author line counts.
func (*Repo) CommitAtDate ¶
CommitAtDate finds the closest commit SHA at or before the given date.
func (*Repo) CurrentBranch ¶
CurrentBranch returns the current branch name, or "HEAD" if detached.
func (*Repo) IsClean ¶
IsClean returns true if the working tree and index have no uncommitted changes.
func (*Repo) LastCommitTime ¶
LastCommitTime returns the relative time of the last commit (e.g. "3 hours ago").
func (*Repo) ListFiles ¶
ListFiles returns the list of git-tracked files for the given ref. If ref is empty, uses the index (working tree tracked files). It respects .gitignore and --exclude patterns if running against the working tree.