git

package
v0.0.0-...-5566b07 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterDefault = "ACMR"
)

Variables

This section is empty.

Functions

func Config

func Config(options ...types.Option) (string, error)

func DetectGitDir

func DetectGitDir() (string, error)

func DiffIndex

func DiffIndex(options ...types.Option) (string, error)

func DiffTree

func DiffTree(options ...types.Option) (string, error)

func ExtractBranchFromRefPath

func ExtractBranchFromRefPath(head string) string

func IsZeroHash

func IsZeroHash(hash string) bool

IsZeroHash indicates if commit hash is a zero hash 0000000000000000000000000000000000000000

func Log

func Log(options ...types.Option) (string, error)

func RevParse

func RevParse(options ...types.Option) (string, error)

func SetDebug

func SetDebug(debug bool) types.Option

func SetExecutor

func SetExecutor(executor types.Executor) types.Option

Types

type Repo

type Repo interface {
	// Path returns the path to the repositories root directory
	Path() string

	// GitDir returns the path to the .git directory of the repository
	GitDir() string

	// HookExists tells you if a hook script for a given hook exists
	HookExists(hook string) bool

	// HooksDir returns the path to the repositories hooks directory
	HooksDir() string

	// CommitMessage creates a CommitMessage type from a message file and returns it
	CommitMessage(path string) (*types.CommitMessage, error)

	// PrepareCommitMessage will write the commit message back to the file
	PrepareCommitMessage(path string, msg *types.CommitMessage) error

	// ConfigValue will return a git config value
	ConfigValue(value string, defaultValue string) string

	// IsMerging tells you if the repository is in a merging state
	IsMerging() bool

	// StagedFiles returns a list of staged files
	StagedFiles() ([]string, error)

	// ChangedFiles returns a list of changed files
	ChangedFiles(from, to string) ([]string, error)

	// BranchName returns the current branch name
	BranchName() string

	// CommitsBetween returns a list of Commit between two hashes
	CommitsBetween(from string, to string) []*types.Commit
}

type Repository

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

func NewRepository

func NewRepository(gitDir string) (*Repository, error)

func (*Repository) BranchName

func (r *Repository) BranchName() string

func (*Repository) ChangedFiles

func (r *Repository) ChangedFiles(from, to string) ([]string, error)

func (*Repository) CommitMessage

func (r *Repository) CommitMessage(path string) (*types.CommitMessage, error)

func (*Repository) CommitsBetween

func (r *Repository) CommitsBetween(from string, to string) []*types.Commit

func (*Repository) ConfigValue

func (r *Repository) ConfigValue(value string, defaultValue string) string

func (*Repository) GitDir

func (r *Repository) GitDir() string

func (*Repository) HookExists

func (r *Repository) HookExists(hook string) bool

func (*Repository) HooksDir

func (r *Repository) HooksDir() string

func (*Repository) IsMerging

func (r *Repository) IsMerging() bool

func (*Repository) Path

func (r *Repository) Path() string

func (*Repository) PrepareCommitMessage

func (r *Repository) PrepareCommitMessage(path string, msg *types.CommitMessage) error

func (*Repository) StagedFiles

func (r *Repository) StagedFiles() ([]string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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