Documentation
¶
Overview ¶
Package git encapsulates git command and branch verification functionality.
Index ¶
- Constants
- func FormatAsValidRef(s string) string
- func GetBranchName(base, key, title string) string
- func GetLengthWithUpperbound(s []string, m int) int
- type Commander
- func (g *Commander) Branch(ctx ExecContext, b string) error
- func (g *Commander) Checkout(ctx ExecContext, b string) error
- func (g *Commander) DiffIndex(ctx ExecContext, t string) error
- func (g *Commander) Remote(ctx ExecContext, args ...string) (string, error)
- func (g *Commander) ShortSymbolicRef(ctx ExecContext) (string, error)
- func (g *Commander) ShowRef(ctx ExecContext, b string) error
- func (g *Commander) Status(ctx ExecContext, args ...string) (string, error)
- type ExecContext
Constants ¶
const ( StatusCmd string = "status" BranchCmd string = "branch" CheckoutCmd string = "checkout" RemoteCmd string = "remote" )
Variables ¶
This section is empty.
Functions ¶
func FormatAsValidRef ¶
FormatAsValidRef transforms `s` to a string that is a valid refname
A reference is used in git to specify branches and tags. The following rules must be followed when is comes to naming references: https://git-scm.com/docs/git-check-ref-format
func GetBranchName ¶
func GetLengthWithUpperbound ¶
Types ¶
type Commander ¶
type Commander struct{}
Commander implements git commands.
func (*Commander) Branch ¶ added in v0.2.0
func (g *Commander) Branch(ctx ExecContext, b string) error
Branch executes `git branch <b>` where b represents the branch name. Returns an error if command execution fails.
func (*Commander) Checkout ¶ added in v0.2.0
func (g *Commander) Checkout(ctx ExecContext, b string) error
Checkout executes `git branch <b>` where b represents the branch name. Returns an error if command execution fails.
func (*Commander) DiffIndex ¶ added in v0.2.0
func (g *Commander) DiffIndex(ctx ExecContext, t string) error
DiffIndex compares a tree `t` to the working tree or index. Returns an error when there is a diff.
func (*Commander) Remote ¶ added in v0.2.0
func (g *Commander) Remote(ctx ExecContext, args ...string) (string, error)
Remote executes `git remote <args>`
func (*Commander) ShortSymbolicRef ¶ added in v0.2.0
func (g *Commander) ShortSymbolicRef(ctx ExecContext) (string, error)
ShortSymbolicRef executes `git symbolic-ref --short HEAD` Returns which branch head the given symbolic ref refers to and outputs its path as first return value. Any error is returned as second return value.
func (*Commander) ShowRef ¶ added in v0.2.0
func (g *Commander) ShowRef(ctx ExecContext, b string) error
ShowRef list references in a local repository. This function can be used to check if a local branch exists or not.