git

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LFSRequiredFile = ".lfs-required"
	LFSConfigFile   = ".lfsconfig"
)
View Source
const (
	NilStep    string = ""
	MergeStep  string = "merge"
	RebaseStep string = "rebase"
)

Variables

This section is empty.

Functions

func IsLFSAvailable added in v1.1.0

func IsLFSAvailable() bool

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

func IsLFSHook added in v1.1.0

func IsLFSHook(hookName string) bool

IsLFSHook returns whether the hookName is supported by Git LFS.

Types

type Exec added in v1.3.0

type Exec interface {
	Cmd(cmd string) (string, error)
	CmdArgs(args ...string) (string, error)
	CmdLines(cmd string) ([]string, error)
	RawCmd(cmd string) (string, error)
}

type OsExec added in v1.3.0

type OsExec struct{}

func NewOsExec added in v1.3.0

func NewOsExec() *OsExec

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

func (*OsExec) Cmd added in v1.3.0

func (o *OsExec) Cmd(cmd string) (string, error)

Cmd runs plain string command. Trims spaces around output.

func (*OsExec) CmdArgs added in v1.3.0

func (o *OsExec) CmdArgs(args ...string) (string, error)

CmdArgs runs a command provided with separted words. Trims spaces around output.

func (*OsExec) CmdLines added in v1.3.0

func (o *OsExec) CmdLines(cmd string) ([]string, error)

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

func (*OsExec) RawCmd added in v1.3.0

func (o *OsExec) RawCmd(cmd string) (string, error)

RawCmd runs a plain string command returning unprocessed output as string.

type Repository

type Repository struct {
	Fs        afero.Fs
	Git       Exec
	HooksPath string
	RootPath  string
	GitPath   string
	InfoPath  string
	// contains filtered or unexported fields
}

Repository represents a git repository.

func NewRepository

func NewRepository(fs afero.Fs, git Exec) (*Repository, error)

NewRepository returns a Repository or an error, if git repository it not initialized.

func (*Repository) AllFiles

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

StagedFiles returns a list of all files in repository or an error if git command fails.

func (*Repository) Branch added in v1.2.2

func (r *Repository) Branch() string

func (*Repository) DropUnstagedStash added in v1.3.0

func (r *Repository) DropUnstagedStash() error

func (*Repository) FilesByCommand added in v1.0.4

func (r *Repository) FilesByCommand(command string) ([]string, error)

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

func (*Repository) HideUnstaged added in v1.3.0

func (r *Repository) HideUnstaged(files []string) error

func (*Repository) PartiallyStagedFiles added in v1.3.0

func (r *Repository) 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 (*Repository) PushFiles

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

PushFiles returns a list of files that are ready to be pushed or an error if git command fails.

func (*Repository) RemoteFolder added in v1.2.0

func (r *Repository) RemoteFolder(url string) string

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

func (*Repository) RemotesFolder added in v1.2.0

func (r *Repository) RemotesFolder() string

RemotesFolder returns the path to the lefthook remotes folder.

func (*Repository) RestoreUnstaged added in v1.3.0

func (r *Repository) RestoreUnstaged() error

func (*Repository) SaveUnstaged added in v1.3.0

func (r *Repository) SaveUnstaged(files []string) error

func (*Repository) StagedFiles

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

StagedFiles returns a list of staged files or an error if git command fails.

func (*Repository) StashUnstaged added in v1.3.0

func (r *Repository) StashUnstaged() error

func (*Repository) State

func (r *Repository) State() State

func (*Repository) SyncRemote added in v1.2.0

func (r *Repository) SyncRemote(url, ref string) error

SyncRemote clones or pulls the latest changes for a git repository that was specified as a remote config repository. If successful, the path to the root of the repository will be returned.

type State

type State struct {
	Branch, Step string
}

Jump to

Keyboard shortcuts

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