scm

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2018 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHeadUnborn is raised when there are no commits yet in the git repo
	ErrHeadUnborn = errors.New("Head commit not found")
)

Functions

func CommitIDs

func CommitIDs(limiter CommitLimiter, wd ...string) ([]string, error)

CommitIDs returns commit SHA1 IDs starting from the head up to the limit

func ConfigRemove

func ConfigRemove(settings map[string]string, wd ...string) error

ConfigRemove removes git configuration settings

func ConfigSet

func ConfigSet(settings map[string]string, wd ...string) error

ConfigSet persists git configuration settings

func CreateNote

func CreateNote(noteTxt string, nameSpace string, wd ...string) error

CreateNote creates a git note associated with the head commit

func GitRepoPath added in v1.3.4

func GitRepoPath(path ...string) (string, error)

GitRepoPath discovers .git directory for a repo

func IgnoreRemove

func IgnoreRemove(ignore string, wd ...string) error

IgnoreRemove removes paths/files ignored for a git repo

func IgnoreSet

func IgnoreSet(ignore string, wd ...string) error

IgnoreSet persists paths/files to ignore for a git repo

func RemoveHooks

func RemoveHooks(hooks map[string]GitHook, p string) error

RemoveHooks remove matching git hook commands

func SetHooks

func SetHooks(hooks map[string]GitHook, wd ...string) error

SetHooks creates git hooks

func Workdir added in v1.3.4

func Workdir(gitRepoPath string) (string, error)

Workdir returns the working directory for a repo

Types

type Commit

type Commit struct {
	ID      string
	OID     *git.Oid
	Summary string
	Message string
	Author  string
	Email   string
	When    time.Time
	Files   []string
	Stats   CommitStats
}

Commit contains commit details

func HeadCommit

func HeadCommit(wd ...string) (Commit, error)

HeadCommit returns the latest commit

type CommitLimiter added in v1.2.1

type CommitLimiter struct {
	Max        int
	DateRange  util.DateRange
	Before     time.Time
	After      time.Time
	Author     string
	Message    string
	HasMax     bool
	HasBefore  bool
	HasAfter   bool
	HasAuthor  bool
	HasMessage bool
}

CommitLimiter struct filter commits by criteria

func NewCommitLimiter added in v1.2.0

func NewCommitLimiter(
	max int, fromDateStr, toDateStr, author, message string,
	today, yesterday, thisWeek, lastWeek,
	thisMonth, lastMonth, thisYear, lastYear bool) (CommitLimiter, error)

NewCommitLimiter returns a new initialize CommitLimiter struct

type CommitNote

type CommitNote struct {
	ID      string
	OID     *git.Oid
	Summary string
	Message string
	Author  string
	Email   string
	When    time.Time
	Note    string
	Stats   CommitStats
}

CommitNote contains a git note's details

func ReadNote

func ReadNote(commitID string, nameSpace string, calcStats bool, wd ...string) (CommitNote, error)

ReadNote returns a commit note for the SHA1 commit id

type CommitStats added in v1.2.1

type CommitStats struct {
	Files        []string
	Insertions   int
	Deletions    int
	FilesChanged int
}

CommitStats contains the files changed and their stats

func DiffParentCommit added in v1.2.1

func DiffParentCommit(childCommit *git.Commit) (CommitStats, error)

DiffParentCommit compares commit to it's parent and returns their stats

func (CommitStats) ChangeRatePerHour added in v1.2.1

func (c CommitStats) ChangeRatePerHour(seconds int) float64

ChangeRatePerHour calculates the rate change per hour

type GitHook added in v1.2.5

type GitHook struct {
	Exe     string
	Command string
	RE      *regexp.Regexp
}

GitHook is the Command with options to be added/removed from a git hook Exe is the executable file name for Linux/MacOS RE is the regex to match on for the command

type Status

type Status struct {
	Files []fileStatus
}

Status contains the git file statuses

func NewStatus

func NewStatus(wd ...string) (Status, error)

NewStatus create a Status struct for a git repo

func (*Status) AddFile

func (s *Status) AddFile(e git.StatusEntry)

AddFile adds a StatusEntry for each file in working and staging directories

func (*Status) HasStaged

func (s *Status) HasStaged() bool

HasStaged returns true if there are any files in staging

func (*Status) IsModified

func (s *Status) IsModified(path string, staging bool) bool

IsModified returns true if the file is modified in either working or staging

func (*Status) IsTracked

func (s *Status) IsTracked(path string) bool

IsTracked returns true if file is tracked by the git repo

Jump to

Keyboard shortcuts

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