Documentation
¶
Overview ¶
Package gitdiff provides functions and types for working with Git diffs in the uncloak application.
Index ¶
Constants ¶
const ( // OriginMain represents the main branch on the remote repository. OriginMain = "origin/main" // LocalMain represents the main branch in the local repository. LocalMain = "main" )
Variables ¶
var ( // ErrNotAGitRepo indicates that the current directory is not a git // repository. ErrNotAGitRepo = errors.New("not a git repository: ensure you are in a git repository or provide a valid file path") // ErrNoParentBranch indicates that no parent branch could be found, which // may occur if the current branch is the main branch. ErrNoParentBranch = errors.New("no parent branch found: are you on the main branch for this repository?") )
var DefaultOptions = Options{}
DefaultOptions provides the default configuration for the git diff command.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
TargetRef string // Target ref for git diff, e.g., "origin/main" or commit hash.
}
Options represents the configuration options for the git diff command.
type Results ¶
Results represents the outcome of a git diff operation, including the root directory, new lines added in each file, and the command used to generate the diff.
func NewResults ¶
NewResults creates a new Results instance by determining the git root directory and initializing the NewLines map. It returns an error if the git root directory cannot be determined.
func Run ¶
Run executes the 'git diff' command with the provided options and parses its output into a Results struct. If opts is nil, it uses DefaultOptions.