git

package
v0.81.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 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 CurrentBranch

func CurrentBranch(cmd CommandRunner) (string, error)

func HeadCommit

func HeadCommit(cmd CommandRunner) (string, error)

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 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) HasBefore added in v0.81.0

func (lns LineNumbers) HasBefore(line int) bool

func (LineNumbers) NearestAfter added in v0.81.0

func (lns LineNumbers) NearestAfter(target int) int

NearestAfter returns the Modified After line number closest to the given target. Only considers entries where Modified is true, consistent with HasAfter. Returns 0 if there are no modified entries with After > 0.

func (LineNumbers) NearestBefore added in v0.81.0

func (lns LineNumbers) NearestBefore(target int) int

NearestBefore returns the Before line number closest to the given target. Returns 0 if there are no entries with Before > 0.

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