gitreviewers

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContributionCounter

type ContributionCounter struct {
	Repo              *gogit.Repository
	ShowFiles         bool
	Verbose           bool
	Since             string
	IgnoredExtensions []string
	OnlyExtensions    []string
	IgnoredPaths      []string
	OnlyPaths         []string
	Mailmap           mailmap
}

ContributionCounter represents a repository and options describing how to count changes and attribute them to collaborators to determine experience.

func (*ContributionCounter) BranchBehind

func (r *ContributionCounter) BranchBehind() (bool, error)

BranchBehind determines if the current branch is "behind" by comparing the current branch HEAD reference to that of the local ref of the master branch.

func (*ContributionCounter) BuildMailmap

func (r *ContributionCounter) BuildMailmap(paths ...string)

BuildMailmap builds a map of author name/email combinations to determine the canonical author for a given line or commit. This is useful if an author worked on a project under multiple identiies but we still want to attribute all contributions to the same person.

It attempts to open and read from any of the paths specified. If none are specified, it will attempt to open ~/.mailmap and read from there.

It will skip over any files it is unable to open without error. If none are parsed, it will result in an empty mailmap.

func (*ContributionCounter) FindFiles

func (r *ContributionCounter) FindFiles() ([]string, error)

FindFiles returns a list of paths to files that have been changed in this branch with respect to "master".

func (*ContributionCounter) FindReviewers

func (r *ContributionCounter) FindReviewers(paths []string) (string, error)

FindReviewers returns up to 3 of the top reviewers information as determined by percentage of owned lines of all lines in changed file.

NOTE: This previously use go-git to create a blame object for each file in 'paths', but the performance and concurrency errors proved to make this unsuitable for this method. We're falling back to making and parsing shell commands to Git to calculate blame statistics.

Relevant src-d/go-git issues - https://github.com/src-d/go-git/issues/457 - https://github.com/src-d/go-git/issues/458

type NoReviewersErr

type NoReviewersErr interface {
	Error() string
	Help() string
}

type Stat

type Stat struct {
	Reviewer   string
	Percentage float64
}

Stat contains information about a collaborator and the total "experience" in a branch as determined by the percentage of lines owned out of the total number of lines of code in a changed file.

func (*Stat) String

func (cs *Stat) String() string

String shows Stat information in a format suitable for shell reporting.

type Stats

type Stats []*Stat

Stats is a collection of all the collaboration statistics obtained across changes in a repository. By defining our own slice type, we are able to add methods to implement the Heap interface, which we use to determine collaborators with the most experience without sorting the entire list.

func (Stats) Len

func (s Stats) Len() int

Len returns the number of Stat objects.

func (Stats) Less

func (s Stats) Less(i, j int) bool

Less sorts Stats by percentage of "owned" lines per collaborator.

func (*Stats) Pop

func (s *Stats) Pop() interface{}

Pop removes the largest Stat from the queue and returns it.

func (*Stats) Push

func (s *Stats) Push(val interface{})

Push adds a stat into the priority queue

func (Stats) Swap

func (s Stats) Swap(i, j int)

Swap moves elements around to their proper location in the heap

Jump to

Keyboard shortcuts

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