gitdiff

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 7 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

This section is empty.

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.

Jump to

Keyboard shortcuts

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