Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyMessage is returned when commit message is empty ErrEmptyMessage = errors.New("commit message is empty") // ErrCommitNotFound is returned when commit file is not found ErrCommitNotFound = errors.New("commit file is not found") )
var ErrBranchNotFound = errors.New("HEAD is not on a branch")
ErrBranchNotFound is returned when repository HEAD is in detached state
var ErrCommandFailed = fmt.Errorf("command failed")
ErrCommandFailed is returned when git command execution fails
var ErrHeadNotFound = errors.New("HEAD file is not found")
ErrHeadNotFound is returned when HEAD file is not found
Functions ¶
func BranchNameFromHead ¶ added in v0.1.4
BranchNameFromHead extracts branch name from raw HEAD content
Types ¶
type Cmd ¶ added in v0.1.4
type Cmd struct { // Cmd is native git command instance *exec.Cmd // contains filtered or unexported fields }
Cmd represents git command
type CommitMessage ¶
CommitMessage represents commit message
func ParseCommitMessage ¶
func ParseCommitMessage(text string) (CommitMessage, error)
ParseCommitMessage parses commit message to parts
func (CommitMessage) Bytes ¶ added in v0.1.4
func (m CommitMessage) Bytes() []byte
Bytes returns byte representation of commit message
func (CommitMessage) String ¶
func (m CommitMessage) String() string
String returns string representation of commit message
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository represents git repository
func NewRepository ¶
func NewRepository(root string) *Repository
NewRepository returns a new Repository instance
func OpenRepository ¶
func OpenRepository(path string) (*Repository, error)
OpenRepository returns a new Repository instance with root of git repository.
func (*Repository) BranchName ¶ added in v0.1.4
func (r *Repository) BranchName() (string, error)
BranchName returns current branch name. If repository is in detached state, returns error
func (*Repository) CommitMessage ¶ added in v0.1.4
func (r *Repository) CommitMessage() (CommitMessage, error)
CommitMessage reads current commit message and parses it to title and body.
func (*Repository) HooksDir ¶ added in v0.1.4
func (r *Repository) HooksDir() (string, error)
HooksDir returns path to the repo hooks directory
func (*Repository) Path ¶
func (r *Repository) Path() string
Path returns path to the git repository
func (*Repository) SetCommitMessage ¶ added in v0.1.4
func (r *Repository) SetCommitMessage(m CommitMessage) error
SetCommitMessage writes commit message to the repository.