Documentation
¶
Overview ¶
Package git wraps the handful of git commands live-pr needs by shelling out, rather than pulling in a full git library.
Index ¶
- func CurrentBranch() (string, error)
- func DefaultBase() string
- func FetchPull(number int, base, expectedOID string) (string, error)
- func FileDiff(base string, paths ...string) string
- func FileDiffRange(base, head string, paths ...string) string
- func HasChanges(base, head string) (bool, error)
- func HasUncommittedChanges() (bool, error)
- func MergeBase(base, head string) (string, error)
- func Push(branch string) error
- func RepoRoot() (string, error)
- func ResolveBase(base string) string
- func Show(sha string) string
- func ShowStat(sha string) string
- type ChangeStats
- type ChangedFile
- type Commit
- type MergeReadiness
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentBranch ¶
CurrentBranch returns the checked-out branch name (e.g. "main", "feature/x").
func DefaultBase ¶
func DefaultBase() string
DefaultBase returns the branch to compare against: the remote's default (origin/HEAD, e.g. "origin/main") when known, else a local main/master, falling back to "main".
func FetchPull ¶
FetchPull fetches a GitHub pull ref and its base without changing HEAD, the index, or the worktree. It returns the namespaced local head ref.
func FileDiffRange ¶
FileDiffRange returns the colorized base...head patch for selected paths.
func HasChanges ¶
HasChanges reports whether base...head contains any changed paths.
func HasUncommittedChanges ¶
HasUncommittedChanges reports whether the index, worktree, or untracked files differ from HEAD.
func ResolveBase ¶
ResolveBase turns a GitHub base name into the freshest local Git revision, preferring its origin remote-tracking ref when available.
Types ¶
type ChangeStats ¶
type ChangeStats struct {
Files, Additions, Deletions int
}
ChangeStats summarizes a diff range for PR list metadata.
func DiffStats ¶
func DiffStats(base, head string) (ChangeStats, error)
DiffStats returns file and line counts for base...head. Binary files count toward Files but not line totals.
type ChangedFile ¶
ChangedFile is one entry in base...HEAD.
func ChangedFiles ¶
func ChangedFiles(base string) ([]ChangedFile, error)
ChangedFiles returns changed paths in base...HEAD order.
func ChangedFilesRange ¶
func ChangedFilesRange(base, head string) ([]ChangedFile, error)
ChangedFilesRange returns changed paths in base...head order.
type Commit ¶
Commit is a git commit reduced to what the timeline needs.
func CommitsRange ¶
CommitsRange returns commits in base..head, oldest first.
type MergeReadiness ¶ added in v0.2.0
MergeReadiness describes how far head trails base and which paths conflict.
func CheckMergeReadiness ¶ added in v0.2.0
func CheckMergeReadiness(base, head string) (MergeReadiness, error)
CheckMergeReadiness simulates merging head into base without touching HEAD, the index, or the worktree.