git

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCommitLines

func ParseCommitLines(
	authors string,
	from, to *time.Time,
	params *TypeFuncParams,
) (ok bool, result interface{}, err error)

ParseCommitLines - Tries to convert a lines of text into a slice of Commits If the format is not a valid one, an error is returned Returns true on first return parameter if there was data available

func ParseDirNames

func ParseDirNames(dirs string) ([]string, error)

func ParseLine

func ParseLine(commit *Commit, line string)

ParseLine - keeps adding field data to the commit struct

func RepoNameFromPath

func RepoNameFromPath(p string) (string, error)

func RunGitLog

func RunGitLog(directory string) (io.Reader, error)

Types

type Author

type Author struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

Author - The person which created the commit

func (*Author) TrimEmailChars

func (t *Author) TrimEmailChars() string

type Change

type Change struct {
	Added    int    `json:"added"`
	Deleted  int    `json:"removed"`
	Filename string `json:"filename"`
}

Change: represents the file name with full path, the number of additions and the number of removals

type Commit

type Commit struct {
	Hash    string    `json:"hash"`
	Author  *Author   `json:"author"`
	Date    time.Time `json:"date"` // for the sake of simplicity we deal only with AuthorDate
	Comment string    `json:"-"`    // issues with JSON.parse(), need more rework
	Added   int64     `json:"added"`
	Deleted int64     `json:"removed"`
	Changes []Change  `json:"changes"`
}

Commit - Type that holds the information about one single commit

type Commits

type Commits []*Commit

func (Commits) FilesToMap

func (t Commits) FilesToMap(files []*RepoFile) map[string]*RepoFileInfo

func (Commits) Filter

func (t Commits) Filter(authors []string, from, to *time.Time) Commits

func (Commits) Len

func (t Commits) Len() int

func (Commits) Less

func (t Commits) Less(i, j int) bool

func (Commits) ReadFiles

func (t Commits) ReadFiles(repoPath string) []*RepoFile

func (Commits) Swap

func (t Commits) Swap(i, j int)

type RepoCommitCollection

type RepoCommitCollection struct {
	Name    string    `json:"name"`
	Commits []*Commit `json:"commits"`
	MinDate int64     `json:"minDate"`
	MaxDate int64     `json:"maxDate"`
	// each key is the extension and the value is the sum of its sizes and the count of each file type
	FileStat map[string]*RepoFileInfo `json:"fileStat"`
}

type RepoFile

type RepoFile struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
}

type RepoFileInfo

type RepoFileInfo struct {
	Size  int64 `json:"size"`
	Count int   `json:"count"`
}

type TypeFuncParams

type TypeFuncParams struct {
	Name     string
	FullPath string
	Commits  interface{}
}

Jump to

Keyboard shortcuts

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