gitstatus

package module
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: MIT Imports: 13 Imported by: 10

README

Build Status Go Report Card Go Reference

gitstatus

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

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 whether HEAD is not associated to any branch
	// (detached).
	IsDetached bool

	// IsInitial reports whether 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 whether 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 NewWithContext added in v0.4.3

func NewWithContext(ctx context.Context) (*Status, error)

NewWithContext is likes New but includes a context.

The provided context is used to stop retrieving git status if the context becomes done before all calls to git have completed.

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