git

package
v0.85.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitMessage added in v0.17.0

func CommitMessage(cmd CommandRunner, sha string) (string, error)

func CountLines added in v0.40.1

func CountLines(body []byte) int

func RunGit

func RunGit(args ...string) (content []byte, err error)

Types

type BodyDiff added in v0.40.1

type BodyDiff struct {
	Before []byte
	After  []byte
	Lines  LineNumbers
}

type CommandRunner

type CommandRunner func(args ...string) ([]byte, error)

type FileChange added in v0.40.1

type FileChange struct {
	Path    PathDiff
	Body    BodyDiff
	Commits []string
	Status  FileStatus
}

func Changes added in v0.40.1

func Changes(cmd CommandRunner, baseBranch string, filter PathFilter) ([]*FileChange, error)

type FileStatus added in v0.40.1

type FileStatus rune
const (
	FileAdded       FileStatus = 'A'
	FileCopied      FileStatus = 'C'
	FileDeleted     FileStatus = 'D'
	FileRenamed     FileStatus = 'R'
	FileModified    FileStatus = 'M'
	FileTypeChanged FileStatus = 'T'
)

type Info added in v0.82.3

type Info struct {
	HeadCommit    string
	CurrentBranch string
}

func Describe added in v0.82.3

func Describe(cmd CommandRunner) (Info, error)

type LineNumber added in v0.81.0

type LineNumber struct {
	Before   int
	After    int
	Modified bool
}

func (LineNumber) String added in v0.81.0

func (ln LineNumber) String() string

type LineNumbers added in v0.81.0

type LineNumbers []LineNumber

func MakeLineRangeFromTo added in v0.81.0

func MakeLineRangeFromTo(first, last int, side LineRangeSide) LineNumbers

func (LineNumbers) BeforeForAfter added in v0.81.0

func (lns LineNumbers) BeforeForAfter(line int) int

BeforeForAfter returns the old (before the change) line number for a given new (after the change) line number.

LineNumbers contains explicit mappings for changed, deleted, added, and shifted lines. Unchanged lines that were not shifted are not stored.

Returns:

  • Before value if the line is present in LineNumbers.
  • Line itself if no mapping exists (unchanged and unshifted).

func (LineNumbers) HasAfter added in v0.81.0

func (lns LineNumbers) HasAfter(line int) bool

func (LineNumbers) HasAnyAfter added in v0.83.0

func (lns LineNumbers) HasAnyAfter(line int) bool

func (LineNumbers) HasBefore added in v0.81.0

func (lns LineNumbers) HasBefore(line int) bool

func (LineNumbers) Nearest added in v0.83.0

func (lns LineNumbers) Nearest(target, rangeFirst, rangeLast int) (int, bool)

Nearest finds the closest line to the target within changedLines. It prefers lines after the target over lines before and lines within the range, but can select nearest line outside of the range if needed. Returns (0, false) if there are no usable entries.

func (LineNumbers) String added in v0.81.0

func (lns LineNumbers) String() string

type LineRangeSide added in v0.81.0

type LineRangeSide uint8
const (
	LinesBefore LineRangeSide = iota
	LinesAfter
	LinesBoth
)

type Path added in v0.40.1

type Path struct {
	Name          string
	SymlinkTarget string
	Type          PathType
}

func (Path) EffectivePath added in v0.40.1

func (p Path) EffectivePath() string

type PathDiff added in v0.40.1

type PathDiff struct {
	Before Path
	After  Path
}

type PathFilter added in v0.51.0

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

func NewPathFilter added in v0.51.0

func NewPathFilter(include, exclude, relaxed []*regexp.Regexp) PathFilter

func (PathFilter) IsPathAllowed added in v0.51.0

func (pf PathFilter) IsPathAllowed(path string) (ok bool)

func (PathFilter) IsRelaxed added in v0.51.0

func (pf PathFilter) IsRelaxed(path string) bool

type PathType added in v0.40.1

type PathType uint8
const (
	Missing PathType = iota
	Dir
	File
	Symlink
)

type TypeDiff added in v0.40.1

type TypeDiff struct {
	Before PathType
	After  PathType
}

Jump to

Keyboard shortcuts

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