git

package
v0.0.0-...-aa656b0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

* Wraps access to data needed from Git. * * We invoke Git directly as a subprocess and parse the output rather than using * git2go/libgit2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitsWithOpts

func CommitsWithOpts(
	ctx context.Context,
	revs []string,
	pathspecs []string,
	filters cmd.LogFilters,
	populateDiffs bool,
	configFiles config.SupplementalFiles,
) (
	iter.Seq[Commit],
	func() error,
)

Returns a single-use iterator over commits identified by the given revisions and paths.

func GetRoot

func GetRoot() (_ string, err error)

func IsSupportedPathspec

func IsSupportedPathspec(pathspec string) bool

* We only support the "exclude" pathspec magic.

func LimitDiffsByPathspec

func LimitDiffsByPathspec(
	commits iter.Seq[Commit],
	pathspecs []string,
) (iter.Seq[Commit], error)

Returns all commits in the input iterator, but for each commit, strips out any file diff not modifying one of the given pathspecs

func ParseArgs

func ParseArgs(args []string) (revs []string, pathspecs []string, err error)

Handles splitting the Git revisions from the pathspecs given a list of args.

We call git rev-parse to disambiguate.

func ParseCommits

func ParseCommits(lines iter.Seq[string]) (iter.Seq[Commit], func() error)

Turns an iterator over lines from git log into an iterator of commits

func PathspecMatch

func PathspecMatch(pathspec string, p string) bool

Function might panic if passed an invalid pathspec. We validate these elsewhere.

func RevList

func RevList(
	ctx context.Context,
	revranges []string,
	pathspecs []string,
	filters cmd.LogFilters,
) (_ []string, err error)

func SkipIgnored

func SkipIgnored(
	commits iter.Seq[Commit],
	ignoreRevs []string,
) iter.Seq[Commit]

Returns an iterator over commits that skips any revs in the given list.

func SplitPathspecs

func SplitPathspecs(pathspecs []string) (includes []string, excludes []string)

* Splits the include pathspecs from the exclude pathspecs. * * For the exclude pathspecs, we also strip off the leading "magic".

func WorkingTreeFiles

func WorkingTreeFiles(pathspecs []string) (_ map[string]bool, err error)

Returns all paths in the working tree under the given pathspecs.

Types

type Commit

type Commit struct {
	Hash        string
	ShortHash   string
	IsMerge     bool
	AuthorName  string
	AuthorEmail string
	Date        time.Time
	FileDiffs   []FileDiff
}

func (Commit) Name

func (c Commit) Name() string

func (Commit) String

func (c Commit) String() string

type FileDiff

type FileDiff struct {
	Path         string
	LinesAdded   int
	LinesRemoved int
}

A file that was changed in a Commit.

func (FileDiff) String

func (d FileDiff) String() string

Directories

Path Synopsis
* Handles invoking Git as a subprocess.
* Handles invoking Git as a subprocess.
* Handles reading Git configuration.
* Handles reading Git configuration.

Jump to

Keyboard shortcuts

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