vcs

package
v0.0.0-...-5ce2981 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRemoteName is the alias used by default for the git remote repository
	DefaultRemoteName = "origin"
	// DefaultPushEnabled indicates the default state for git auto-push option
	DefaultPushEnabled = false
)

Variables

This section is empty.

Functions

func GetGitCommandPath

func GetGitCommandPath() string

GetGitCommandPath returns the path to git command on this machine

func GetGitCommandVersion

func GetGitCommandVersion() string

GetGitCommandVersion returns the version of git command on this machine

func GetGitUserName

func GetGitUserName() string

GetGitUserName returns the user name retrieved from local git configuration

func IsGitCommandAvailable

func IsGitCommandAvailable() bool

IsGitCommandAvailable indicates if git command is available on local machine

func IsRootBranch

func IsRootBranch(branch string) bool

IsRootBranch tells if the provided branch is a root branch or not. Current implementation is a trivial one, that returns true if the branch is called "main" or "master"

Types

type FileDiff

type FileDiff struct {
	Path string
	// contains filtered or unexported fields
}

FileDiff is a structure containing diff information for a file

func NewFileDiff

func NewFileDiff(filename string, added int, removed int) FileDiff

NewFileDiff creates a new instance of FileDiff

func (FileDiff) ChangedLines

func (fd FileDiff) ChangedLines() int

ChangedLines returns the number of changed lines for this file

type FileDiffs

type FileDiffs []FileDiff

FileDiffs contains a set of FileDiff data in a slice

func (FileDiffs) ChangedLines

func (diffs FileDiffs) ChangedLines(predicate func(filepath string) bool) (changes int)

ChangedLines returns the total number of changed lines for this set of files

type GitInterface

type GitInterface interface {
	GetRootDir() string
	GetRemoteName() string
	GetWorkingBranch() string
	Add(paths ...string) error
	Commit(amend bool, messages ...string) error
	Restore(dir string) error
	Revert() error
	Push() error
	Pull() error
	Stash(message string) error
	UnStash(keep bool) error
	Diff() (diffs FileDiffs, err error)
	Log(msgFilter func(msg string) bool) (logs GitLogItems, err error)
	EnablePush(flag bool)
	IsPushEnabled() bool
	IsRemoteEnabled() bool
	CheckRemoteAccess() bool
}

GitInterface provides the interface that a git implementation must satisfy for TCR engine to be able to interact with git

func New

func New(dir string) (GitInterface, error)

New initializes the git implementation based on the provided directory from local clone

type GitLogItem

type GitLogItem struct {
	Hash      string
	Timestamp time.Time
	Message   string
}

GitLogItem contains git log information for a commit

func NewGitLogItem

func NewGitLogItem(hash string, timestamp time.Time, message string) GitLogItem

NewGitLogItem creates a new git log item instance

type GitLogItems

type GitLogItems []GitLogItem

GitLogItems contains a set of git log items in a slice

Jump to

Keyboard shortcuts

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