gitstatus

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 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 Porcelain added in v0.4.0

type Porcelain 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.

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

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

	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.
}

Porcelain holds the Git status variables extracted from calling git status --porcelain.

type Status

type Status struct {
	Porcelain

	NumStashed int // NumStashed is the number of stash entries.

	HEAD string // HEAD is the shortened SHA1 of current commit (empty in initial state).

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

	// 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.

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

Jump to

Keyboard shortcuts

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