diff

package
v0.0.0-...-ec59030 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package diff implements `gitmap diff LEFT RIGHT`: a read-only preview of what `gitmap merge-both / merge-left / merge-right` would change. No files are written, no commits, no pushes.

Spec: companion to spec/01-app/97-move-and-merge.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Report

func Report(out io.Writer, entries []Entry, opts PrintOptions) error

Report renders the entries to out per opts (text or JSON).

Types

type Endpoint

type Endpoint struct {
	Raw         string
	DisplayName string
	WorkingDir  string
}

Endpoint is a fully classified LEFT or RIGHT argument.

`gitmap diff` only supports local folders. URL endpoints are rejected with a hint to clone them first; this keeps `diff` strictly read-only and side-effect-free.

func ResolveEndpoint

func ResolveEndpoint(raw string) (Endpoint, error)

ResolveEndpoint validates that raw points at an existing folder and returns its absolute path.

type Entry

type Entry struct {
	RelPath    string    `json:"path"`
	Kind       EntryKind `json:"-"`
	KindLabel  string    `json:"kind"`
	LeftSize   int64     `json:"left_size,omitempty"`
	RightSize  int64     `json:"right_size,omitempty"`
	LeftMTime  int64     `json:"left_mtime,omitempty"`
	RightMTime int64     `json:"right_mtime,omitempty"`
}

Entry is one path classified for the diff report.

func DiffTrees

func DiffTrees(leftDir, rightDir string, opts WalkOptions) ([]Entry, error)

DiffTrees walks LEFT and RIGHT and returns every classified entry, sorted ascending by relative path.

type EntryKind

type EntryKind int

EntryKind classifies how a single relative path differs.

const (
	// MissingRight = present on LEFT, absent on RIGHT.
	MissingRight EntryKind = iota
	// MissingLeft = present on RIGHT, absent on LEFT.
	MissingLeft
	// Identical = present on both, byte-equal.
	Identical
	// Conflict = present on both, byte-different.
	Conflict
)

type PrintOptions

type PrintOptions struct {
	OnlyConflicts    bool
	OnlyMissing      bool
	IncludeIdentical bool
	JSON             bool
}

PrintOptions controls the human-readable report layout.

type Summary

type Summary struct {
	MissingLeft  int `json:"missing_left"`
	MissingRight int `json:"missing_right"`
	Conflicts    int `json:"conflicts"`
	Identical    int `json:"identical"`
}

Summary is the per-kind tally returned alongside the entries.

func SummaryFor

func SummaryFor(entries []Entry) Summary

SummaryFor counts kinds across an Entry slice.

type WalkOptions

type WalkOptions struct {
	IncludeVCS         bool
	IncludeNodeModules bool
}

WalkOptions controls which files participate in the diff.

Jump to

Keyboard shortcuts

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