git2graph

package
v0.0.0-...-208395f Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Pipe      pointType = iota // 0: |
	MergeBack                  // 1: ┘
	Fork                       // 2: ┐
	MergeTo                    // 3: ┌
)

Types; to understand these constants, you need to read the graph from top to bottom. Fork is when a node fork into two paths (top -> bottom) MergeBack is when a branch merge back into a branch on its right MergeTo is when a branch on the right merge into a branch on its left

View Source
const (
	BottomHalfLine = 0
	TopHalfLine    = 1
	FullLine       = 2
	ForkLine       = 3
	MergeBackLine  = 4
)

Variables

View Source
var DefaultColors = []string{
	"#005EBE",
	"#CD3A00",
	"#FF9B00",
	"#007754",
	"#5247A5",
	"#009DB5",
	"#007DFF",
	"#FF6C3B",
	"#FFB800",
	"#3EBD90",
	"#776CCB",
	"#00C4E0",
}

DefaultColors Default colors

View Source
var NoOutput = false

NoOutput No output

Functions

func SerializeOutput

func SerializeOutput(out *Out)

SerializeOutput Json encode object

Types

type CycleColorGen

type CycleColorGen struct {
	// contains filtered or unexported fields
}

CycleColorGen ...

func NewCycleColorGen

func NewCycleColorGen(colors []string) *CycleColorGen

NewCycleColorGen creates a new CycleColorGen

func (*CycleColorGen) GetColor

func (c *CycleColorGen) GetColor(idx int) string

type IColorGenerator

type IColorGenerator interface {
	GetColor(idx int) string
}

type IPoint

type IPoint interface {
	SetX(int)
	GetY() int

	Equal(IPoint) bool
	String() string
	// contains filtered or unexported methods
}

type Node

type Node map[string]any

Node is the raw information for a commit

func GetInputNodesFromFile

func GetInputNodesFromFile(filePath string) (nodes []*Node, err error)

GetInputNodesFromFile creates an array of Node from json contained in a file

func GetInputNodesFromJSON

func GetInputNodesFromJSON(inputJSON []byte) (nodes []*Node, err error)

GetInputNodesFromJSON Get nodes from json object

func GetInputNodesFromRepo

func GetInputNodesFromRepo(dir string, order Order, limit int) (nodes []*Node, err error)

GetInputNodesFromRepo creates an array of Node from a repository

func GetInputNodesFromRepoSeq

func GetInputNodesFromRepoSeq(dir string, order Order, limit int) (nodes []*Node, err error)

GetInputNodesFromRepoSeq creates an array of Node from a repository. Replace sha by sequential IDs.

func (*Node) GetID

func (n *Node) GetID() string

func (*Node) GetParents

func (n *Node) GetParents() []string

type Order

type Order int
const (
	DefaultOrder Order = iota
	DateOrder
	TopoOrder
)

type Out

type Out struct {
	FirstSha     string
	Nodes        []*Node
	PartialPaths []*PartialPath
}

func Get

func Get(inputNodes []*Node) (*Out, error)

func GetPaginated

func GetPaginated(inputNodes []*Node, from string, limit int) (*Out, error)

GetPaginated gets the necessary information to render the graph for the asked page

func GetPaginatedRows

func GetPaginatedRows(inputNodes []*Node, from string, limit int) (*Out, error)

GetPaginatedRows gets the information to render the graph as rows

func GetRows

func GetRows(inputNodes []*Node) (*Out, error)

type PartialPath

type PartialPath struct {
	Points []IPoint
	Color  string
}

type Path

type Path struct {
	Points []IPoint
	// contains filtered or unexported fields
}

Path defines how to draw a line in between a parent and child nodes

func (*Path) GetHeightAtIdx

func (p *Path) GetHeightAtIdx(lookupIdx int) (height int)

GetHeightAtIdx Get the path x at idx

type PathTest

type PathTest struct {
	Points []*PointTest
	// contains filtered or unexported fields
}

type Point

type Point struct {
	// contains filtered or unexported fields
}

Point is one part of a path

func (*Point) Equal

func (p *Point) Equal(other IPoint) bool

func (*Point) GetY

func (p *Point) GetY() int

func (*Point) MarshalJSON

func (p *Point) MarshalJSON() ([]byte, error)

func (*Point) SetX

func (p *Point) SetX(v int)

func (*Point) String

func (p *Point) String() string

type PointTest

type PointTest struct {
	// contains filtered or unexported fields
}

func (*PointTest) Equal

func (p *PointTest) Equal(other IPoint) bool

func (*PointTest) GetY

func (p *PointTest) GetY() int

func (*PointTest) SetX

func (p *PointTest) SetX(v int)

func (*PointTest) String

func (p *PointTest) String() string

type SimpleColorGen

type SimpleColorGen struct {
	// contains filtered or unexported fields
}

SimpleColorGen is a color generator that take a static colors array, or return black when running out of colors

func NewSimpleColorGen

func NewSimpleColorGen(colors []string) *SimpleColorGen

NewSimpleColorGen creates a new SimpleColorGen

func (*SimpleColorGen) GetColor

func (c *SimpleColorGen) GetColor(idx int) string

Jump to

Keyboard shortcuts

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