gitdiff

package
v0.0.0-...-6cfbf2b Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugEnabled bool

Functions

func ApplyHunks

func ApplyHunks(hunkIDs []string, hunksByID map[string]*Hunk, baseDiff string) error

ApplyHunks applies specific hunks to the git staging area using dependency-aware grouping.

func ApplyHunksWithFallback

func ApplyHunksWithFallback(hunkIDs []string, hunksByID map[string]*Hunk, baseDiff string) error

ApplyHunksWithFallback applies hunks using the hunk-based approach only.

func CreateDependencyGroups

func CreateDependencyGroups(hunks []*Hunk) [][]*Hunk

CreateDependencyGroups groups hunks based on their dependencies for atomic application.

func CreateHunkPatch

func CreateHunkPatch(hunks []*Hunk, baseDiff string) string

CreateHunkPatch creates a patch file containing only the specified hunks. This is the public interface for creating patches from hunks.

func DisableDebug

func DisableDebug()

DisableDebug disables debug logging

func EnableDebug

func EnableDebug()

EnableDebug enables debug logging

func PreviewHunkApplication

func PreviewHunkApplication(hunkIDs []string, hunksByID map[string]*Hunk) string

PreviewHunkApplication generates a preview of what would be applied when staging these hunks.

func ResetStagingArea

func ResetStagingArea() bool

ResetStagingArea resets the staging area to match HEAD.

func ValidateHunkCombination

func ValidateHunkCombination(hunks []*Hunk) error

ValidateHunkCombination validates that a combination of hunks can be applied together.

func ValidatePatchFormat

func ValidatePatchFormat(patchContent string) bool

ValidatePatchFormat validates that a patch has proper git patch format.

Types

type Hunk

type Hunk struct {
	ID           string          `json:"id"`
	FilePath     string          `json:"file_path"`
	StartLine    int             `json:"start_line"`
	EndLine      int             `json:"end_line"`
	Content      string          `json:"content"`
	Context      string          `json:"context"`
	Dependencies map[string]bool `json:"dependencies"` // Hunk IDs this depends on
	Dependents   map[string]bool `json:"dependents"`   // Hunk IDs that depend on this
	ChangeType   string          `json:"change_type"`  // addition, deletion, modification
	IsNewFile    bool            `json:"is_new_file"`  // true if the file is newly added
}

Hunk represents an individual hunk (change block) from a git diff.

func ParseDiff

func ParseDiff(diffOutput string) ([]*Hunk, error)

ParseDiff parses git diff output into individual hunks.

type StagingStatus

type StagingStatus struct {
	Staged   []string `json:"staged"`
	Modified []string `json:"modified"`
}

StagingStatus represents the current staging status

func GetStagingStatus

func GetStagingStatus() StagingStatus

GetStagingStatus gets the current staging status.

Jump to

Keyboard shortcuts

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