gitdiff

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gitdiff provides functions and types for working with Git diffs in the uncloak application.

Index

Constants

View Source
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

View Source
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?")
)
View Source
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

type Results struct {
	RootDir  string
	NewLines map[string]map[int]bool
	Command  string
}

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

func NewResults(command string) (*Results, error)

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

func Run(opts *Options) (*Results, error)

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.

func (*Results) Files

func (d *Results) Files() []string

Files returns a sorted list of unique file paths that have new lines in the git diff.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL