gitparse

package
v3.0.0-...-838862a Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit

type Commit struct {
	Hash    string
	Author  string
	Date    time.Time
	Message strings.Builder
	Diffs   []Diff
	Size    int // in bytes
}

Commit contains commit header info and diffs.

func (*Commit) Equal

func (c1 *Commit) Equal(c2 *Commit) bool

Equal compares the content of two Commits to determine if they are the same.

type Diff

type Diff struct {
	PathB     string
	LineStart int
	Content   bytes.Buffer
	IsBinary  bool
}

Diff contains the info about a file diff in a commit.

type Option

type Option func(*Parser)

Option is used for adding options to Config.

func WithMaxCommitSize

func WithMaxCommitSize(maxCommitSize int) Option

WithMaxCommitSize sets maxCommitSize option. Commits larger than maxCommitSize will be put in the commit channel and additional diffs will be added to a new commit.

func WithMaxDiffSize

func WithMaxDiffSize(maxDiffSize int) Option

WithMaxDiffSize sets maxDiffSize option. Diffs larger than maxDiffSize will be truncated.

type ParseState

type ParseState int
const (
	Initial ParseState = iota
	CommitLine
	MergeLine
	AuthorLine
	DateLine
	MessageStartLine
	MessageLine
	MessageEndLine
	DiffLine
	ModeLine
	IndexLine
	FromFileLine
	ToFileLine
	BinaryFileLine
	HunkLineNumberLine
	HunkContentLine
	ParseFailure
)

func (ParseState) String

func (state ParseState) String() string

type Parser

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

Parser sets values used in GitParse.

func NewParser

func NewParser(options ...Option) *Parser

NewParser creates a GitParse config from options and sets defaults.

func (*Parser) FromReader

func (c *Parser) FromReader(ctx context.Context, stdOut io.Reader, commitChan chan Commit, isStaged bool)

func (*Parser) RepoPath

func (c *Parser) RepoPath(ctx context.Context, source string, head string, abbreviatedLog bool, excludedGlobs []string, isBare bool) (chan Commit, error)

RepoPath parses the output of the `git log` command for the `source` path.

func (*Parser) Staged

func (c *Parser) Staged(ctx context.Context, source string) (chan Commit, error)

Staged parses the output of the `git diff` command for the `source` path.

Jump to

Keyboard shortcuts

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