git

package
v2.1.7 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LFSRequiredFile = ".lfs-required"
	LFSConfigFile   = ".lfsconfig"
)
View Source
const (
	Nil         string = ""
	Merge       string = "merge"
	MergeCommit string = "merge-commit"
	Rebase      string = "rebase"
)

Variables

This section is empty.

Functions

func IsLFSAvailable

func IsLFSAvailable() bool

IsLFSAvailable returns 'true' if git-lfs is installed.

func IsLFSHook

func IsLFSHook(hookName string) bool

IsLFSHook returns whether the hookName is supported by Git LFS.

func RemoteDirectoryName added in v2.0.11

func RemoteDirectoryName(url, ref string) string

Types

type Commander added in v2.1.7

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

Commander provides some methods that take some effect on execution and/or result data.

func NewCommander added in v2.1.7

func NewCommander(cmd system.Command, logger *logger.Logger) *Commander

NewCommander returns an object that executes given commands in the OS.

func (Commander) BatchedCmd added in v2.1.7

func (c Commander) BatchedCmd(cmd []string, args []string) (string, error)

BatchedCmd runs the command with any number of appended arguments batched in chunks to match the OS limits.

func (Commander) Cmd added in v2.1.7

func (c Commander) Cmd(cmd []string) (string, error)

Cmd runs plain string command.

func (Commander) CmdLines added in v2.1.7

func (c Commander) CmdLines(cmd []string) ([]string, error)

CmdLines runs plain string command, returns its output split by newline.

func (Commander) CmdLinesWithinFolder added in v2.1.7

func (c Commander) CmdLinesWithinFolder(cmd []string, folder string) ([]string, error)

CmdLinesWithinFolder runs plain string command, returns its output split by newline.

func (Commander) OnlyDebugLogs added in v2.1.7

func (c Commander) OnlyDebugLogs() Commander

func (Commander) WithoutEnvs added in v2.1.7

func (c Commander) WithoutEnvs(envs ...string) Commander

func (Commander) WithoutTrim added in v2.1.7

func (c Commander) WithoutTrim() Commander

type Repo added in v2.1.7

type Repo struct {
	Fs  afero.Fs
	Git *Commander

	HooksPath string
	RootPath  string
	GitPath   string
	InfoPath  string
	// contains filtered or unexported fields
}

Repo represents a git repository.

func NewRepo added in v2.1.7

func NewRepo(
	fs afero.Fs,
	logger *logger.Logger,
) (*Repo, error)

NewRepo returns a Repo or an error, if git repository it not initialized.

func (*Repo) AddFiles added in v2.1.7

func (r *Repo) AddFiles(files []string) error

func (*Repo) AllFiles added in v2.1.7

func (r *Repo) AllFiles() ([]string, error)

AllFiles returns a list of all files in repository.

func (*Repo) CacheGitCommands added in v2.1.7

func (r *Repo) CacheGitCommands() func()

CacheGitCommands runs various Git commands in the background so the results are ready. This returns a function which can be used to wait for the result. This should be invoked to ensure we're not holding any locks on the Git repository.

func (*Repo) CanRestoreUnstagedChanges added in v2.1.7

func (r *Repo) CanRestoreUnstagedChanges() bool

CanRestoreUnstagedChanges checks is a patch with previously unstaged changes can be applied to the current worktree.

func (*Repo) Changeset added in v2.1.7

func (r *Repo) Changeset() (map[string]string, error)

Changeset returns a map of files and their hashes that are different from the index. The hash for a deleted file is "deleted", and "directory" for a directory.

func (*Repo) CloneRemote added in v2.1.7

func (r *Repo) CloneRemote(dest, directoryName, url, ref string) error

func (*Repo) FindAllFiles added in v2.1.7

func (r *Repo) FindAllFiles(command []string, folder string) ([]string, error)

FindAllFiles accepts git command and returns its result as a list of filepaths.

func (*Repo) FindExistingFiles added in v2.1.7

func (r *Repo) FindExistingFiles(command []string, folder string) ([]string, error)

FindExistingFiles accepts git command and returns its result as a list of filepaths.

func (*Repo) PartiallyStagedFiles added in v2.1.7

func (r *Repo) PartiallyStagedFiles() ([]string, error)

PartiallyStagedFiles returns the list of files that have both staged and unstaged changes. See https://git-scm.com/docs/git-status#_short_format.

func (*Repo) PrintDiff added in v2.1.7

func (r *Repo) PrintDiff(files []string)

func (*Repo) PushFiles added in v2.1.7

func (r *Repo) PushFiles() ([]string, error)

PushFiles returns a list of files that are ready to be pushed.

func (*Repo) RemoteFolder added in v2.1.7

func (r *Repo) RemoteFolder(url string, ref string) string

RemoteFolder returns the path to the folder where the remote repository is located.

func (*Repo) RemotesFolder added in v2.1.7

func (r *Repo) RemotesFolder() string

RemotesFolder returns the path to the lefthook remotes folder.

func (*Repo) ResetCache added in v2.1.7

func (r *Repo) ResetCache()

ResetCache must be called after you've constructed a Repository directly. It's not necessary to invoke if you've used NewRepository.

This can also be called multiple times to reset the cache.

func (*Repo) RestoreUnstagedChanges added in v2.1.7

func (r *Repo) RestoreUnstagedChanges() error

RestoreUnstagedChanges applies the patch with previously unstaged changes.

func (*Repo) RevertAllUnstagedChanges added in v2.1.7

func (r *Repo) RevertAllUnstagedChanges() error

func (*Repo) RevertUnstagedChanges added in v2.1.7

func (r *Repo) RevertUnstagedChanges(files []string) error

func (*Repo) SaveUnstagedChanges added in v2.1.7

func (r *Repo) SaveUnstagedChanges(files []string) error

func (*Repo) StagedFiles added in v2.1.7

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

StagedFiles returns a list of staged files which exist on file system.

func (*Repo) StagedFilesWithDeleted added in v2.1.7

func (r *Repo) StagedFilesWithDeleted() ([]string, error)

StagedFilesWithDeleted returns a list of staged files with deleted files.

func (*Repo) State added in v2.1.7

func (r *Repo) State() State

func (*Repo) UpdateRemote added in v2.1.7

func (r *Repo) UpdateRemote(path, ref string) error

func (*Repo) WithLogger added in v2.1.7

func (repo *Repo) WithLogger(logger *logger.Logger) *Repo

type State

type State struct {
	Branch, State string
}

Jump to

Keyboard shortcuts

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