git

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package git provides functionality for working with git repositories.

This package includes constants defining template names for git hooks and initializes the templates from embedded files on package initialization.

The package embeds files from a 'templates/' directory which contain hook templates that can be used for git operations such as preparing commit messages.

Index

Constants

View Source
const (
	// HookPrepareCommitMessageTemplate is the template for the prepare-commit-msg hook
	HookPrepareCommitMessageTemplate = "prepare-commit-msg"
	// CommitMessageTemplate is the template for the commit message
	CommitMessageTemplate = "commit-msg.tmpl"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command added in v0.0.5

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

func New added in v0.0.5

func New(opts ...Option) *Command

New creates a new Command object with the provided options. It applies each option to the config object and initializes the Command object with the configurations.

func (*Command) Commit added in v0.0.6

func (c *Command) Commit(val string) (string, error)

Commit creates a git commit with the provided message and returns the output or an error. It uses the commit method to generate the git command and execute it.

func (*Command) DiffFiles added in v0.0.5

func (c *Command) DiffFiles() (string, error)

Diff compares the differences between two sets of data. It returns a string representing the differences and an error. If there are no differences, it returns an empty string and an error. DiffFiles compares the differences between two sets of data and returns the differences as a string and an error. It first lists the names of changed files and then shows the differences between them. If there are no staged changes, it returns an error message.

func (*Command) GitDir added in v0.2.0

func (c *Command) GitDir() (string, error)

GitDir to show the (by default, absolute) path of the git directory of the working tree.

func (*Command) InstallHook added in v0.0.6

func (c *Command) InstallHook() error

InstallHook installs the prepare-commit-msg hook if it doesn't already exist. It retrieves the hooks directory path, checks if the hook file exists, and writes the hook file with executable permissions.

func (*Command) UninstallHook added in v0.0.6

func (c *Command) UninstallHook() error

UninstallHook removes the prepare-commit-msg hook if it exists. It retrieves the hooks directory path, checks if the hook file exists, and removes the hook file.

type Option added in v0.0.7

type Option interface {
	// contains filtered or unexported methods
}

Option is an interface that specifies instrumentation configuration options.

func WithDiffUnified added in v0.0.7

func WithDiffUnified(val int) Option

WithDiffUnified is a function that generate diffs with <n> lines of context instead of the usual three.

func WithEnableAmend added in v0.1.0

func WithEnableAmend(val bool) Option

WithEnableAmend returns an Option that sets the isAmend field of a config object to the given value.

func WithExcludeList added in v0.0.8

func WithExcludeList(val []string) Option

WithExcludeList returns an Option that sets the excludeList field of a config object to the given value.

Jump to

Keyboard shortcuts

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