Documentation
¶
Overview ¶
Package git provides easy execution of git commands.
Index ¶
- func Commit(msg string) error
- func CoreEditorValue() (string, error)
- func CoreGlobalEditorValue() (string, error)
- func CurrentBranch() (string, error)
- func Diff(opt DiffOptions) (string, error)
- func IsInWorkTree() bool
- func MergeMsg() (string, error)
- func ResetFile(filePath string, isUntracked bool) error
- func RootFolder() (string, error)
- func StageAll() error
- func StageFile(path string) error
- func UnstageAll() error
- func UnstageFile(path string) error
- type DiffOptions
- type FileStatus
- type FileStatusList
- type StatusCode
- type WorkTreeStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CoreEditorValue ¶ added in v0.2.0
CoreEditorValue returns the currently set local editor for git Can be used to direclty open files.
func CoreGlobalEditorValue ¶ added in v0.2.0
CoreEditorValue returns the currently set global editor for git Can be used to direclty open files.
func CurrentBranch ¶
CurrentBranch returns the name of the current current branch or an error.
func Diff ¶
func Diff(opt DiffOptions) (string, error)
Diff performs a `git diff“ with the given options.
func IsInWorkTree ¶ added in v0.4.0
func IsInWorkTree() bool
func ResetFile ¶
ResetFile either resets the file to the index or deletes it in case it is untracked.
func RootFolder ¶ added in v0.4.0
RootFolder returns the git root folder.
func UnstageFile ¶
UnstageFile unstages a file at the given path.
Types ¶
type DiffOptions ¶
type FileStatus ¶
type FileStatus struct { Path string // The Path of the file Extra string // Contains extra information, e.g. old name UnstagedStatusCode StatusCode // Working tree status StagedStatusCode StatusCode // Index status }
FileStatus represents the git status of a file. It shows the status in the working tree and in the index.
func (FileStatus) HasStagedChanges ¶
func (fs FileStatus) HasStagedChanges() bool
func (FileStatus) HasUnstagedChanges ¶
func (fs FileStatus) HasUnstagedChanges() bool
func (FileStatus) IsRenamed ¶
func (fs FileStatus) IsRenamed() bool
func (FileStatus) IsUnmodified ¶
func (fs FileStatus) IsUnmodified() bool
func (FileStatus) IsUntracked ¶
func (fs FileStatus) IsUntracked() bool
type FileStatusList ¶
type FileStatusList []FileStatus
func (FileStatusList) Filter ¶
func (fl FileStatusList) Filter(isIncluded func(FileStatus) bool) FileStatusList
Filter returns a new FileStatusList that only includes elements accepted by the passed filter.
func (FileStatusList) StagedFiles ¶
func (fl FileStatusList) StagedFiles() FileStatusList
StagedFiles returns all files that have staged changes.
func (FileStatusList) UnstagedFiles ¶
func (fl FileStatusList) UnstagedFiles() FileStatusList
UnstagedFiles returns all files that have unstaged changes.
type StatusCode ¶
type StatusCode byte
StatusCode of a file.
const ( Unmodified StatusCode = ' ' Modified StatusCode = 'M' TypeChanged StatusCode = 'T' Added StatusCode = 'A' Deleted StatusCode = 'D' Renamed StatusCode = 'R' Copied StatusCode = 'C' UpdatedButUnmerged StatusCode = 'U' Untracked StatusCode = '?' Ignored StatusCode = '!' )
type WorkTreeStatus ¶
type WorkTreeStatus struct { // The branch at the time of creation. // Can be empty if not requested. Branch string CleanedBranchName string // List of staged and unstaged files FileStatusList }
WorkTreeStatus represents the current status of the git work tree.
func Status ¶
func Status() (WorkTreeStatus, error)
Status retrieves the current `git status` represented by WorkTreeStatus object.