Documentation ¶
Index ¶
Constants ¶
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 ¶
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 ¶
NewFileDiff creates a new instance of FileDiff
func (FileDiff) ChangedLines ¶
ChangedLines returns the number of changed lines for this file
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 ¶
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