git

package
v0.0.0-...-6dcb528 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: MIT Imports: 14 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)

Config sets up a `git config` cli command

func DetectGitDir

func DetectGitDir() (string, error)

func DiffIndex

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

DiffIndex sets up a `git diff-index` cli command

func DiffTree

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

DiffTree sets up a `git diff-tree` cli command

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)

Log sets up a `git log` command

func RevParse

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

RevParse sets up a `git rev-parse` cli command

func SetDebug

func SetDebug(debug bool) types.Option

SetDebug is there to activate debugging for command executions

func SetExecutor

func SetExecutor(executor types.Executor) types.Option

SetExecutor is the way to substitute the default execution model for testing purposes

Types

type Repo

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

	// AbsPath returns the absolute path to the root directory
	AbsPath() 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) AbsPath

func (r *Repository) AbsPath() string

AbsPath returns the absolute path to the repository and the relative path as fallback

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