git

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package git holds the git source adapters. "git-history" scans the added lines of every commit (git log -p) and "git-staged" the added lines of the index. Both emit one chunk per file per commit (or per staged file) whose line k is line k of the file's post-image, with lines that were not added left empty, so detection reports post-image line numbers and pairs multi-part credentials within the file. They run git only through internal/gitx. Commit messages, diff text and emails never leave this package.

Index

Constants

View Source
const (
	// History is the adapter that scans the whole history, or a range of it.
	History = "git-history"
	// Staged is the adapter that scans the staged changes.
	Staged = "git-staged"
)

Adapter names.

Variables

View Source
var (
	// ErrNoPath: the spec has no repository path.
	ErrNoPath = errors.New("git source: no path")
	// ErrGitNotFound: no git binary on PATH.
	ErrGitNotFound = gitx.ErrNotFound
	// ErrNotRepo: the path is not inside a git work tree.
	ErrNotRepo = gitx.ErrNotRepo
	// ErrBadRef: the since ref is invalid or does not resolve to a commit.
	ErrBadRef = gitx.ErrBadRef
)

Errors returned by the adapter factories, for the front door to turn into messages.

Functions

func NewHistory

func NewHistory(spec source.Spec) (source.Source, error)

NewHistory returns the git-history source for spec.Path, limited by spec.Since, spec.Until and spec.ExcludeRemotes.

func NewStaged

func NewStaged(spec source.Spec) (source.Source, error)

NewStaged returns the git-staged source for spec.Path.

Types

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source is one git source.

func (*Source) History

func (s *Source) History() (ran bool, commits int)

History reports whether the history walk ran and how many commits it walked. A staged source never ran a history walk.

func (*Source) Name

func (s *Source) Name() string

Name returns the path as given, with forward slashes.

func (*Source) Scan

func (s *Source) Scan(ctx context.Context, emit func(candidate.Chunk) bool, warn func(model.Warning)) error

Scan streams the added lines of the history or of the index. A stream that ends in a git failure is returned as a read_failed warning error.

func (*Source) Target

func (s *Source) Target() model.Target

Target returns the repo target, the same one the fs source reports.

Jump to

Keyboard shortcuts

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