Documentation ¶
Index ¶
- Constants
- func IsLFSAvailable() bool
- func IsLFSHook(hookName string) bool
- type CommandExecutor
- type Executor
- type Repository
- func (r *Repository) AddFiles(files []string) error
- func (r *Repository) AllFiles() ([]string, error)
- func (r *Repository) Branch() string
- func (r *Repository) DropUnstagedStash() error
- func (r *Repository) FilesByCommand(command []string) ([]string, error)
- func (r *Repository) HideUnstaged(files []string) error
- func (r *Repository) PartiallyStagedFiles() ([]string, error)
- func (r *Repository) PushFiles() ([]string, error)
- func (r *Repository) RemoteFolder(url string, ref string) string
- func (r *Repository) RemotesFolder() string
- func (r *Repository) RestoreUnstaged() error
- func (r *Repository) SaveUnstaged(files []string) error
- func (r *Repository) StagedFiles() ([]string, error)
- func (r *Repository) StashUnstaged() error
- func (r *Repository) State() State
- func (r *Repository) SyncRemote(url, ref string, force bool) error
- type State
Constants ¶
const ( LFSRequiredFile = ".lfs-required" LFSConfigFile = ".lfsconfig" )
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.
Types ¶
type CommandExecutor ¶ added in v1.6.9
type CommandExecutor struct {
// contains filtered or unexported fields
}
CommandExecutor provides some methods that take some effect on execution and/or result data.
func NewExecutor ¶ added in v1.6.9
func NewExecutor(exec Executor) *CommandExecutor
NewExecutor returns an object that executes given commands in the OS.
func (CommandExecutor) BatchedCmd ¶ added in v1.6.9
func (c CommandExecutor) 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 (CommandExecutor) Cmd ¶ added in v1.6.9
func (c CommandExecutor) Cmd(args []string) (string, error)
Cmd runs plain string command. Trims spaces around output.
func (CommandExecutor) CmdLines ¶ added in v1.6.9
func (c CommandExecutor) CmdLines(cmd []string) ([]string, error)
CmdLines runs plain string command, returns its output split by newline.
func (CommandExecutor) CmdLinesWithinFolder ¶ added in v1.6.9
func (c CommandExecutor) CmdLinesWithinFolder(cmd []string, folder string) ([]string, error)
CmdLines runs plain string command, returns its output split by newline.
type Executor ¶ added in v1.6.9
Executor is a general execution interface for implicit commands. Added here mostly for mockable tests.
type Repository ¶
type Repository struct { Fs afero.Fs Git *CommandExecutor 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 *CommandExecutor) (*Repository, error)
NewRepository returns a Repository or an error, if git repository it not initialized.
func (*Repository) AddFiles ¶ added in v1.3.5
func (r *Repository) AddFiles(files []string) error
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, ref 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, force bool) 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.