Documentation
¶
Overview ¶
Package gitgraph is mermaid git graph diagram builder.
Index ¶
- type BranchOption
- type CherryPickOption
- type CommitOption
- type CommitType
- type Diagram
- func (d *Diagram) Branch(name string, opts ...BranchOption) *Diagram
- func (d *Diagram) Build() error
- func (d *Diagram) Checkout(name string) *Diagram
- func (d *Diagram) CherryPick(id string, opts ...CherryPickOption) *Diagram
- func (d *Diagram) Commit(opts ...CommitOption) *Diagram
- func (d *Diagram) Error() error
- func (d *Diagram) LF() *Diagram
- func (d *Diagram) Merge(branch string, opts ...CommitOption) *Diagram
- func (d *Diagram) Reset(id string) *Diagram
- func (d *Diagram) String() string
- type Option
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BranchOption ¶
type BranchOption func(*branchConfig)
BranchOption sets branch options.
func WithBranchOrder ¶
func WithBranchOrder(order int) BranchOption
WithBranchOrder sets the branch order. Order must be zero or greater.
type CherryPickOption ¶
type CherryPickOption func(*cherryPickConfig)
CherryPickOption sets cherry-pick options.
func WithCherryPickParent ¶
func WithCherryPickParent(parentID string) CherryPickOption
WithCherryPickParent sets the cherry-pick parent commit id.
type CommitOption ¶
type CommitOption func(*commitConfig)
CommitOption sets commit options.
func WithCommitType ¶
func WithCommitType(cType CommitType) CommitOption
WithCommitType sets the commit type.
type CommitType ¶
type CommitType string
CommitType is the commit style in git graph.
const ( // CommitTypeNormal is default commit style. CommitTypeNormal CommitType = "NORMAL" // CommitTypeReverse is reverse commit style. CommitTypeReverse CommitType = "REVERSE" // CommitTypeHighlight is highlight commit style. CommitTypeHighlight CommitType = "HIGHLIGHT" )
type Diagram ¶
type Diagram struct {
// contains filtered or unexported fields
}
Diagram is a git graph diagram builder.
Example ¶
ExampleDiagram skips this test on Windows. The newline codes in the comment section where the expected values are written are represented as '\n', causing failures when testing on Windows.
package main
import (
"io"
"os"
md "github.com/nao1215/markdown"
"github.com/nao1215/markdown/mermaid/gitgraph"
)
func main() {
diagram := gitgraph.NewDiagram(
io.Discard,
gitgraph.WithTitle("Release Flow"),
).
Commit(gitgraph.WithCommitID("init"), gitgraph.WithCommitTag("v0.1.0")).
Branch("develop").
Checkout("develop").
Commit(gitgraph.WithCommitType(gitgraph.CommitTypeHighlight)).
Checkout("main").
Merge("develop", gitgraph.WithCommitTag("v1.0.0")).
String()
_ = md.NewMarkdown(os.Stdout).
H2("Git Graph").
CodeBlocks(md.SyntaxHighlightMermaid, diagram).
Build()
}
Output: ## Git Graph ```mermaid --- title: Release Flow --- gitGraph commit id: "init" tag: "v0.1.0" branch develop checkout develop commit type: HIGHLIGHT checkout main merge develop tag: "v1.0.0" ```
func NewDiagram ¶
NewDiagram returns a new Diagram.
func (*Diagram) Branch ¶
func (d *Diagram) Branch(name string, opts ...BranchOption) *Diagram
Branch adds a branch command to the git graph.
func (*Diagram) CherryPick ¶
func (d *Diagram) CherryPick(id string, opts ...CherryPickOption) *Diagram
CherryPick adds a cherry-pick command to the git graph.
func (*Diagram) Commit ¶
func (d *Diagram) Commit(opts ...CommitOption) *Diagram
Commit adds a commit command to the git graph.
func (*Diagram) Error ¶
Error returns the error that occurred during the git graph diagram building.
func (*Diagram) Merge ¶
func (d *Diagram) Merge(branch string, opts ...CommitOption) *Diagram
Merge adds a merge command to the git graph.