gitdiff

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package gitdiff computes the set of added/changed lines per file between a base ref and the working tree, for "new code" (Clean-as-You-Code) gating: a finding is "new" when it sits on a changed line. It shells out to git (argv only, no shell) and parses a --unified=0 diff. Read-only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileAtRevision added in v0.1.8

func FileAtRevision(ctx context.Context, dir, revision, path string) ([]byte, error)

FileAtRevision returns one base-side file while the scan workspace still exists.

func FileChanges added in v0.1.8

func FileChanges(ctx context.Context, dir, base, head string) ([]projectanalysis.FileChange, error)

FileChanges returns normalized immutable Git changes between two already-resolved revisions. It uses argv-only Git and never consults the working tree at read time.

Types

type ChangedLines

type ChangedLines map[string]map[int]bool

ChangedLines maps a repo-relative file path to the set of its added/changed 1-based line numbers.

func Changed

func Changed(ctx context.Context, dir, base string) (ChangedLines, error)

Changed returns the added/changed lines between base and the working tree of dir. base is a git ref (branch, tag, sha); e.g. "origin/main" or a merge-base. It runs `git -C dir diff --unified=0 base -- .`.

func (ChangedLines) Has

func (c ChangedLines) Has(file string, line int) bool

Has reports whether file:line was added/changed.

type ComparisonSource added in v0.1.8

type ComparisonSource struct{}

ComparisonSource adapts Git-backed comparison reads to the use-case port.

func (*ComparisonSource) FileAtRevision added in v0.1.8

func (*ComparisonSource) FileAtRevision(ctx context.Context, dir, revision, path string) ([]byte, error)

func (*ComparisonSource) FileChanges added in v0.1.8

func (*ComparisonSource) FileChanges(ctx context.Context, dir, base, head string) ([]projectanalysis.FileChange, error)

Jump to

Keyboard shortcuts

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