Documentation
¶
Overview ¶
Package git provides interoperability with the local git binary: listing staged files and retrieving their diff content as it will be committed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStagedContent ¶
GetStagedContent returns the full staged blob content for a file. This is used for newly added files (status "A") where there is no base to diff against.
func GetStagedDiff ¶
GetStagedDiff returns the unified diff of staged changes for the given path. Only the added lines (lines beginning with '+') are returned, because those represent new content being introduced into the repository.
func IsInsideWorkTree ¶
func IsInsideWorkTree() bool
IsInsideWorkTree returns true when the current directory is inside a git repo.
Types ¶
type StagedFile ¶
type StagedFile struct {
// Path is the repo-relative path of the file.
Path string
// Status is the single-letter git status code: A (added), M (modified),
// D (deleted), R (renamed), C (copied), etc.
Status string
}
StagedFile represents a single file that has changes staged for commit.
func ListStagedFiles ¶
func ListStagedFiles() ([]StagedFile, error)
ListStagedFiles returns all files currently staged for the next commit. It runs `git diff --cached --name-status` and parses the output. Files with status "D" (deleted) are excluded — there is nothing to scan.