Documentation
¶
Overview ¶
Package git wraps go-git with the helpers uda needs (commit ranges, repo IDs, changed files).
Index ¶
- type CommitDetail
- type CommitFiles
- type CommitRange
- type FileChange
- type Repository
- func (r *Repository) CommitChangedFiles(hashes []plumbing.Hash) ([]CommitFiles, error)
- func (r *Repository) CommitDetails(hashes []plumbing.Hash) ([]CommitDetail, error)
- func (r *Repository) Commits(commitRange *CommitRange) ([]plumbing.Hash, error)
- func (r *Repository) CommitsSince(d time.Duration) ([]plumbing.Hash, error)
- func (r *Repository) CommitsWithin(d time.Duration, end time.Time) ([]plumbing.Hash, error)
- func (r *Repository) Repo() *git.Repository
- func (r *Repository) RepoID() string
- func (r *Repository) ResolveCommit(commitish string) (plumbing.Hash, error)
- func (r *Repository) RootPath() string
- func (r *Repository) WorkingTreeChangedFiles() ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommitDetail ¶
type CommitDetail struct {
SHA string
Message string
Timestamp time.Time
Files []FileChange
}
CommitDetail holds full commit info with file-level stats.
type CommitFiles ¶
CommitFiles holds files changed in a single commit.
type CommitRange ¶
CommitRange represents a range of commits to analyze.
func ParseCommitRange ¶
func ParseCommitRange(repo *Repository, rangeStr string) (*CommitRange, error)
ParseCommitRange parses a commit range string. Supported formats:
- "abc123" - single commit
- "abc123..def456" - range from abc123 (exclusive) to def456 (inclusive)
type FileChange ¶
FileChange holds change stats for a single file.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository wraps a go-git repository with additional utilities.
func OpenRepository ¶
func OpenRepository(path string) (*Repository, error)
OpenRepository opens a git repository at the given path. Returns an error if the path is not a git repository.
func (*Repository) CommitChangedFiles ¶
func (r *Repository) CommitChangedFiles(hashes []plumbing.Hash) ([]CommitFiles, error)
CommitChangedFiles returns the files changed in each commit.
func (*Repository) CommitDetails ¶
func (r *Repository) CommitDetails(hashes []plumbing.Hash) ([]CommitDetail, error)
CommitDetails returns detailed commit info with file stats.
func (*Repository) Commits ¶
func (r *Repository) Commits(commitRange *CommitRange) ([]plumbing.Hash, error)
Commits returns the list of commits in the range, ordered from oldest to newest. For a single commit (From == nil and no ".." in original), returns just that commit. For a range, returns commits from From (exclusive) to To (inclusive). If the range is backwards (From is not an ancestor of To), it automatically flips.
func (*Repository) CommitsSince ¶
CommitsSince returns commits from the last d duration, oldest first.
func (*Repository) CommitsWithin ¶
CommitsWithin returns commits in the window [end-d, end], oldest first. An explicit end keeps history-derived analyses anchored to the data (e.g. a review head's commit time) instead of the wall clock.
func (*Repository) Repo ¶
func (r *Repository) Repo() *git.Repository
Repo returns the underlying go-git repository.
func (*Repository) RepoID ¶
func (r *Repository) RepoID() string
RepoID returns a unique identifier for the repository. This is a hash of the origin URL if available, otherwise a hash of the path.
func (*Repository) ResolveCommit ¶
func (r *Repository) ResolveCommit(commitish string) (plumbing.Hash, error)
ResolveCommit resolves a commit-ish string (e.g., "HEAD", "main", "abc123") to a concrete commit hash.
func (*Repository) RootPath ¶
func (r *Repository) RootPath() string
RootPath returns the root path of the repository.
func (*Repository) WorkingTreeChangedFiles ¶
func (r *Repository) WorkingTreeChangedFiles() ([]string, error)
WorkingTreeChangedFiles returns the paths (relative to the repo root) that differ between the working tree and HEAD, including staged and untracked files.