whatchanged

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package whatchanged produces the "what changed" delta between two GitOps revisions: a path-scoped unified diff (the actual landed change). It is the differentiating core of RunLore's investigation spine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCloneCache

func WithCloneCache(ctx context.Context) (context.Context, func())

WithCloneCache returns a derived context carrying a clone cache, plus a cleanup func that removes every clone the cache created. Wrap a batch of diffs that may hit the same repo (the what_changed tool's change loop) so each source repo is cloned at most once; call the returned func when the batch is done.

Types

type Differ

type Differ struct {
	// TokenSource mints a GitHub App installation token for HTTPS clone auth in
	// Remote/RemoteFromParent. It is called once per clone so a short-lived
	// (~1h) installation token stays fresh across a long-running agent. nil
	// disables auth (e.g. public or local repos).
	TokenSource func(context.Context) (string, error)
}

Differ computes path-scoped diffs between Git revisions.

func (*Differ) ForChange

func (d *Differ) ForChange(ctx context.Context, c providers.Change) (providers.Diff, error)

ForChange resolves the diff for a detected Change by cloning its source repo and scoping to the workload's path. With both revisions it diffs FromRev..ToRev; with only ToRev it diffs the change introduced by ToRev (against its parent). ctx bounds the clone + patch so a caller deadline (per-investigation timeout) aborts a hung remote.

func (*Differ) Local

func (d *Differ) Local(ctx context.Context, path, fromRev, toRev, scope string) (providers.Diff, error)

Local diffs two revisions in an already-cloned repository at path. ctx bounds the (potentially expensive) patch computation so a caller deadline is honored.

func (*Differ) Remote

func (d *Differ) Remote(ctx context.Context, url, fromRev, toRev, scope string) (providers.Diff, error)

Remote clones url to disk (auth via the installation token when set) and diffs two revisions. The source may be a remote HTTPS URL or a local path. ctx bounds the clone + patch.

func (*Differ) RemoteFromParent

func (d *Differ) RemoteFromParent(ctx context.Context, url, rev, scope string) (providers.Diff, error)

RemoteFromParent clones url and returns the path-scoped diff of the change introduced by rev (rev against its first parent). A root commit (no parent) yields an empty diff. ctx bounds the clone + patch.

NOTE (perf): does a full (disk) clone per call. When the GitOpsProvider drives this across many changes, add a per-repo clone cache here (see dev/plans note).

Jump to

Keyboard shortcuts

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