Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountLines ¶
CountLines counts non-empty lines, used for git stash list.
func Diff ¶ added in v0.3.0
func Diff(root string, f FileStatus) (string, error)
Diff returns the patch for one changed path. When both the index and the working tree changed it joins the staged and unstaged diffs, and for an untracked file it synthesises a new-file patch.
func FormatWhen ¶
FormatWhen renders a short relative time, or a month-day date after two weeks.
Types ¶
type FileStatus ¶ added in v0.3.0
type FileStatus struct {
Path string
OrigPath string
Index byte
Worktree byte
Untracked bool
Unmerged bool
}
FileStatus is one changed path. Index is the staged code and Worktree is the unstaged code, using the porcelain-v2 letters ('.' means unchanged).
func (FileStatus) Code ¶ added in v0.3.0
func (f FileStatus) Code() string
Code renders the two status columns, for example "M ", " M", or "??".
func (FileStatus) Staged ¶ added in v0.3.0
func (f FileStatus) Staged() bool
Staged reports whether the index differs from HEAD.
func (FileStatus) Unstaged ¶ added in v0.3.0
func (f FileStatus) Unstaged() bool
Unstaged reports whether the working tree differs from the index.
type Status ¶
type Status struct {
Branch string
Upstream string
Ahead int
Behind int
Staged int
Unstaged int
Stash int
Detached bool
Dirty map[string]struct{}
// Files lists each changed path in the order git reports it.
Files []FileStatus
}
Status is a branch and worktree summary from git status --porcelain=v2 --branch. Untracked paths count as unstaged.
func ParseStatus ¶
ParseStatus parses porcelain v2 output that includes the branch header.