Documentation
¶
Overview ¶
Package types defines the core data structures shared across git-branch-tree.
Index ¶
- func ModeStrings() []string
- func RendererStrings() []string
- type BranchCommitMap
- type BranchInfo
- type BranchInfoMap
- type BranchInfosMap
- type BranchName
- type BranchNamesSet
- type Commit
- type CommitHash
- type CommitHashMap
- type CommitToBranchInfoMap
- type Mode
- type Node
- type NodeMap
- type Renderer
- type UpstreamMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ModeStrings ¶
func ModeStrings() []string
ModeStrings returns a slice of all String values of the enum
func RendererStrings ¶
func RendererStrings() []string
RendererStrings returns a slice of all String values of the enum
Types ¶
type BranchCommitMap ¶
type BranchCommitMap map[BranchName][]CommitHash
BranchCommitMap maps each branch to its commit history, ordered from HEAD (index 0) to the initial commit.
type BranchInfo ¶
type BranchInfo struct {
// Name is the canonical branch name, used as a lookup key.
Name BranchName
// DisplayName is the name as printed; may contain ANSI colour codes.
DisplayName string
// LatestAncestor is the parent branch in the tree; empty string for roots.
LatestAncestor BranchName
// HEAD is the hash of the tip commit of the branch.
HEAD CommitHash
}
BranchInfo holds display and ancestry metadata for a single branch.
type BranchInfoMap ¶
type BranchInfoMap map[BranchName]*BranchInfo
BranchInfoMap maps a branch name to its BranchInfo.
type BranchInfosMap ¶
type BranchInfosMap map[BranchName][]*BranchInfo
BranchInfosMap maps a branch name to all BranchInfos that have it as their LatestAncestor.
type BranchName ¶
type BranchName string
BranchName is a git branch name. It is a short name by default, or a full ref (e.g. refs/heads/main) when FullRefs is enabled.
type BranchNamesSet ¶
type BranchNamesSet map[BranchName]struct{}
BranchNamesSet is a set of branch names.
func (BranchNamesSet) Equals ¶
func (bns BranchNamesSet) Equals(bns2 BranchNamesSet) bool
Equals reports whether bns and bns2 contain exactly the same branch names.
type Commit ¶
type Commit struct {
// Hash is the commit's hash.
Hash CommitHash
// BranchNames is the set of all branches whose history includes this commit.
BranchNames BranchNamesSet
}
Commit holds metadata about a single git commit.
type CommitHashMap ¶
type CommitHashMap map[CommitHash]*Commit
CommitHashMap maps each commit hash to its Commit metadata.
type CommitToBranchInfoMap ¶
type CommitToBranchInfoMap map[CommitHash]*BranchInfo
CommitToBranchInfoMap maps a commit hash to the BranchInfo of the branch whose HEAD is that commit. Used during node collapsing.
type Mode ¶
type Mode int
Mode controls how parent-child relationships between branches are determined.
func ModeString ¶
ModeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
type Node ¶
type Node struct {
// Val is the node's value - a BranchInfo.
Val *BranchInfo
// ChildNodes is a list of this node's children.
ChildNodes []*Node
}
Node is a tree node that satisfies the ppds.Node interface. It is used as the common in-memory tree representation passed to all renderers.
func (*Node) Children ¶
Children returns the node's children as a []ppdstree.Node slice, satisfying the ppds.Node interface. See https://github.com/golang/go/wiki/InterfaceSlice for why the conversion cannot be done more directly.
type NodeMap ¶
type NodeMap map[BranchName]*Node
NodeMap maps a branch name to its Node. The empty-string key ("") is the synthetic root node used by renderers that walk the map directly (GoTree, TreeDrawer, TreePrint).
type Renderer ¶
type Renderer int
Renderer selects which third-party library is used to draw the branch tree.
const ( // GoTree is github.com/d6o/GoTree. GoTree Renderer = iota // TreeDrawer is github.com/m1gwings/treedrawer (no colour support). TreeDrawer // PPDSVertical is github.com/shivamMg/ppds, vertical layout. PPDSVertical // PPDSHorizontal is github.com/shivamMg/ppds, horizontal layout. PPDSHorizontal // PPDSHorizontalNewline is github.com/shivamMg/ppds, horizontal layout with newlines (default). PPDSHorizontalNewline // TreePrint is github.com/xlab/treeprint. TreePrint )
func RendererString ¶
RendererString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func RendererValues ¶
func RendererValues() []Renderer
RendererValues returns all values of the enum
func (Renderer) IsARenderer ¶
IsARenderer returns "true" if the value is listed in the enum definition. "false" otherwise
type UpstreamMap ¶
type UpstreamMap map[BranchName]BranchName
UpstreamMap maps each branch to its upstream tracking branch. An empty string value means the branch has no upstream and is treated as a root.