Documentation
¶
Index ¶
- Constants
- func IsLFSAvailable() bool
- func IsLFSHook(hookName string) bool
- func RemoteDirectoryName(url, ref string) string
- type CommandExecutor
- func (c CommandExecutor) BatchedCmd(cmd []string, args []string) (string, error)
- func (c CommandExecutor) Cmd(cmd []string) (string, error)
- func (c CommandExecutor) CmdLines(cmd []string) ([]string, error)
- func (c CommandExecutor) CmdLinesWithinFolder(cmd []string, folder string) ([]string, error)
- func (c CommandExecutor) OnlyDebugLogs() CommandExecutor
- func (c CommandExecutor) WithoutEnvs(envs ...string) CommandExecutor
- func (c CommandExecutor) WithoutTrim() CommandExecutor
- type Repository
- func (r *Repository) AddFiles(files []string) error
- func (r *Repository) AllFiles() ([]string, error)
- func (r *Repository) Changeset() (map[string]string, error)
- func (r *Repository) DropUnstagedStash() error
- func (r *Repository) FindAllFiles(command []string, folder string) ([]string, error)
- func (r *Repository) FindExistingFiles(command []string, folder string) ([]string, error)
- func (r *Repository) HideUnstaged(files []string) error
- func (r *Repository) PartiallyStagedFiles() ([]string, error)
- func (r *Repository) Precompute() func()
- func (r *Repository) PrintDiff(files []string)
- 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) Setup()
- func (r *Repository) StagedFiles() ([]string, error)
- func (r *Repository) StagedFilesWithDeleted() ([]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 ( 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 RemoteDirectoryName ¶ added in v2.0.11
Types ¶
type CommandExecutor ¶
type CommandExecutor struct {
// contains filtered or unexported fields
}
CommandExecutor provides some methods that take some effect on execution and/or result data.
func NewExecutor ¶
func NewExecutor(cmd system.Command) *CommandExecutor
NewExecutor returns an object that executes given commands in the OS.
func (CommandExecutor) BatchedCmd ¶
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 ¶
func (c CommandExecutor) Cmd(cmd []string) (string, error)
Cmd runs plain string command.
func (CommandExecutor) CmdLines ¶
func (c CommandExecutor) CmdLines(cmd []string) ([]string, error)
CmdLines runs plain string command, returns its output split by newline.
func (CommandExecutor) CmdLinesWithinFolder ¶
func (c CommandExecutor) CmdLinesWithinFolder(cmd []string, folder string) ([]string, error)
CmdLinesWithinFolder runs plain string command, returns its output split by newline.
func (CommandExecutor) OnlyDebugLogs ¶
func (c CommandExecutor) OnlyDebugLogs() CommandExecutor
func (CommandExecutor) WithoutEnvs ¶
func (c CommandExecutor) WithoutEnvs(envs ...string) CommandExecutor
func (CommandExecutor) WithoutTrim ¶
func (c CommandExecutor) WithoutTrim() CommandExecutor
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 ¶
func (r *Repository) AddFiles(files []string) error
func (*Repository) AllFiles ¶
func (r *Repository) AllFiles() ([]string, error)
AllFiles returns a list of all files in repository.
func (*Repository) Changeset ¶
func (r *Repository) 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 (*Repository) DropUnstagedStash ¶
func (r *Repository) DropUnstagedStash() error
func (*Repository) FindAllFiles ¶
func (r *Repository) FindAllFiles(command []string, folder string) ([]string, error)
FindAllFiles accepts git command and returns its result as a list of filepaths.
func (*Repository) FindExistingFiles ¶
func (r *Repository) FindExistingFiles(command []string, folder string) ([]string, error)
FindExistingFiles accepts git command and returns its result as a list of filepaths.
func (*Repository) HideUnstaged ¶
func (r *Repository) HideUnstaged(files []string) error
func (*Repository) PartiallyStagedFiles ¶
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) Precompute ¶
func (r *Repository) Precompute() func()
Precompute 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 (*Repository) PrintDiff ¶ added in v2.0.12
func (r *Repository) PrintDiff(files []string)
func (*Repository) PushFiles ¶
func (r *Repository) PushFiles() ([]string, error)
PushFiles returns a list of files that are ready to be pushed.
func (*Repository) RemoteFolder ¶
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 ¶
func (r *Repository) RemotesFolder() string
RemotesFolder returns the path to the lefthook remotes folder.
func (*Repository) RestoreUnstaged ¶
func (r *Repository) RestoreUnstaged() error
func (*Repository) SaveUnstaged ¶
func (r *Repository) SaveUnstaged(files []string) error
func (*Repository) Setup ¶
func (r *Repository) Setup()
Setup 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 (*Repository) StagedFiles ¶
func (r *Repository) StagedFiles() ([]string, error)
StagedFiles returns a list of staged files which exist on file system.
func (*Repository) StagedFilesWithDeleted ¶
func (r *Repository) StagedFilesWithDeleted() ([]string, error)
StagedFilesWithDeleted returns a list of staged files with deleted files.
func (*Repository) StashUnstaged ¶
func (r *Repository) StashUnstaged() error
func (*Repository) State ¶
func (r *Repository) State() State
func (*Repository) SyncRemote ¶
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.