gitstatus

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: MIT Imports: 12 Imported by: 10

README

gitstatus: retrieve the Git status of a working tree, in Go.

Build Status Coverage Go Report Card GoDoc

License MIT

See LICENSE file

Documentation

Overview

Package gitstatus provides information about the git status of a working tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formater

type Formater interface {
	// Format returns the string representation of a given Status.
	Format(*Status) (string, error)
}

Formater is the interface implemented by objects having a Format method.

type Status

type Status struct {
	NumModified  int // NumModified is the number of modified files.
	NumConflicts int // NumConflicts is the number of unmerged files.
	NumUntracked int // NumUntracked is the number of untracked files.
	NumStaged    int // NumStaged is the number of staged files.
	NumStashed   int // NumStashed is the number of stash entries.

	HEAD         string // HEAD is the shortened SHA1 of current commit (empty in initial state).
	LocalBranch  string // LocalBranch is the name of the local branch.
	RemoteBranch string // RemoteBranch is the name of upstream remote branch (tracking).
	AheadCount   int    // AheadCount reports by how many commits the local branch is ahead of its upstream branch.
	BehindCount  int    // BehindCount reports by how many commits the local branch is behind its upstream branch.

	// State indicates the state of the working tree.
	State TreeState

	// IsInitial reports wether the working tree is in its initial state (no
	// commit have been performed yet).
	IsInitial bool

	// IsDetached reports wether HEAD is not associated to any branch
	// (detached).
	IsDetached bool

	// IsClean reports wether the working tree is in a clean state (i.e empty
	// staging area, no conflicts, no stash entries, no untracked files).
	IsClean bool
}

Status represents the status of a Git working tree directory.

func New

func New() (*Status, error)

New returns the Git Status of the current working directory.

func (*Status) ReadFrom

func (st *Status) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom reads and parses git porcelain status from the given reader, filling the corresponding status fields.

type TreeState

type TreeState int

TreeState indicates the state of a Git working tree. Its zero-value is NormalState.

const (
	// Default is state set when the working tree is not in any special state.
	Default TreeState = iota

	// Rebasing is the state set when a rebase is in progress, either
	// interactive or manual.
	Rebasing

	// AM is the state set when a git AM is in progress (mailbox patch).
	AM

	// AMRebase is the state set when a git AM rebasing is in progress.
	AMRebase

	// Merging is the state set when a merge is in progress.
	Merging

	// CherryPicking is the state when a cherry-pick is in progress.
	CherryPicking

	// Reverting is the state when a revert is in progress.
	Reverting

	// Bisecting is the state when a bisect is in progress.
	Bisecting
)

func (TreeState) MarshalJSON

func (s TreeState) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the tree state.

func (TreeState) String

func (i TreeState) String() string

Directories

Path Synopsis
cmd
gitstatus command
format

Jump to

Keyboard shortcuts

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