commitstats

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2019 License: Apache-2.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 CommitFileStats

type CommitFileStats struct {
	Path     string
	Language string
	Code     KindStats
	Comment  KindStats
	Blank    KindStats
	Other    KindStats
	Total    KindStats
}

CommitFileStats represents the stats for a file in a commit.

func CalculateByFile

func CalculateByFile(r *git.Repository, from, to *object.Commit) ([]CommitFileStats, error)

CalculateByFile calculates the stats for all files from a commit to another. If from is nil, the first parent is used. if the commit is an orphan, the stats are compared against an empty commit.

type CommitStats

type CommitStats struct {
	// Files add/modified/removed by this commit.
	Files int
	// Code stats of the code lines.
	Code KindStats
	// Comment stats of the comment lines.
	Comment KindStats
	// Blank stats of the blank lines.
	Blank KindStats
	// Other stats of files that are not from a recognized or format language.
	Other KindStats
	// Total the sum of the previous stats.
	Total KindStats
}

CommitStats represents the stats for a commit.

func Calculate

func Calculate(r *git.Repository, from, to *object.Commit) (*CommitStats, error)

Calculate calculates the CommitStats for from commit to another. if from is nil the first parent is used, if the commit is orphan the stats are compared against a empty commit.

func (*CommitStats) String

func (s *CommitStats) String() string

type KindStats

type KindStats struct {
	// Additions number of lines added.
	Additions int
	// Deletions number of lines deleted.
	Deletions int
}

KindStats represents the stats for a kind of lines in a file.

func (*KindStats) Add

func (k *KindStats) Add(add KindStats)

Add adds the given stats to this stats.

type LineInfo

type LineInfo struct {
	Kind  LineKind
	Count int
}

LineInfo represents the information about a sigle line.

type LineKind

type LineKind int

LineKind defines the kind of a line in a file.

const (
	// Code represents a line of code.
	Code LineKind = iota + 1
	// Comment represents a line of comment.
	Comment
	// Blank represents an empty line.
	Blank
	// Other represents a line from any other kind.
	Other
)

Jump to

Keyboard shortcuts

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