Documentation
¶
Index ¶
- Constants
- func IsLFSAvailable() bool
- func IsLFSHook(hookName string) bool
- func RemoteDirectoryName(url, ref string) string
- type Commander
- func (c Commander) BatchedCmd(cmd []string, args []string) (string, error)
- func (c Commander) Cmd(cmd []string) (string, error)
- func (c Commander) CmdLines(cmd []string) ([]string, error)
- func (c Commander) CmdLinesWithinFolder(cmd []string, folder string) ([]string, error)
- func (c Commander) OnlyDebugLogs() Commander
- func (c Commander) WithoutEnvs(envs ...string) Commander
- func (c Commander) WithoutTrim() Commander
- type GitPaths
- type Repo
- func (r *Repo) AddFiles(files []string) error
- func (r *Repo) AllFiles() ([]string, error)
- func (r *Repo) CacheGitCommands() func()
- func (r *Repo) CanRestoreUnstagedChanges() bool
- func (r *Repo) Changeset() (map[string]string, error)
- func (r *Repo) CloneRemote(dest, directoryName, url, ref string) error
- func (r *Repo) FindAllFiles(command []string, folder string) ([]string, error)
- func (r *Repo) FindExistingFiles(command []string, folder string) ([]string, error)
- func (r *Repo) PartiallyStagedFiles() ([]string, error)
- func (r *Repo) PrintDiff(files []string)
- func (r *Repo) PushFiles() ([]string, error)
- func (r *Repo) RemoteFolder(url string, ref string) string
- func (r *Repo) RemotesFolder() string
- func (r *Repo) ResetCache()
- func (r *Repo) RestoreUnstagedChanges() error
- func (r *Repo) RevertAllUnstagedChanges() error
- func (r *Repo) RevertUnstagedChanges(files []string) error
- func (r *Repo) SaveUnstagedChanges(files []string) error
- func (r *Repo) StagedFiles() ([]string, error)
- func (r *Repo) StagedFilesWithDeleted() ([]string, error)
- func (r *Repo) State() State
- func (r *Repo) UpdateRemote(path, ref string) error
- func (repo *Repo) WithLogger(logger *logger.Logger) *Repo
- 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 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
NewCommander returns an object that executes given commands in the OS.
func (Commander) BatchedCmd ¶ added in v2.1.7
BatchedCmd runs the command with any number of appended arguments batched in chunks to match the OS limits.
func (Commander) CmdLines ¶ added in v2.1.7
CmdLines runs plain string command, returns its output split by newline.
func (Commander) CmdLinesWithinFolder ¶ added in v2.1.7
CmdLinesWithinFolder runs plain string command, returns its output split by newline.
func (Commander) OnlyDebugLogs ¶ added in v2.1.7
func (Commander) WithoutEnvs ¶ added in v2.1.7
func (Commander) WithoutTrim ¶ added in v2.1.7
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
NewRepo returns a Repo or an error, if git repository it not initialized.
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
CanRestoreUnstagedChanges checks is a patch with previously unstaged changes can be applied to the current worktree.
func (*Repo) Changeset ¶ added in v2.1.7
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 (*Repo) FindAllFiles ¶ added in v2.1.7
FindAllFiles accepts git command and returns its result as a list of filepaths.
func (*Repo) FindExistingFiles ¶ added in v2.1.7
FindExistingFiles accepts git command and returns its result as a list of filepaths.
func (*Repo) PartiallyStagedFiles ¶ added in v2.1.7
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) PushFiles ¶ added in v2.1.7
PushFiles returns a list of files that are ready to be pushed.
func (*Repo) RemoteFolder ¶ added in v2.1.7
RemoteFolder returns the path to the folder where the remote repository is located.
func (*Repo) RemotesFolder ¶ added in v2.1.7
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
RestoreUnstagedChanges applies the patch with previously unstaged changes.
func (*Repo) RevertAllUnstagedChanges ¶ added in v2.1.7
func (*Repo) RevertUnstagedChanges ¶ added in v2.1.7
func (*Repo) SaveUnstagedChanges ¶ added in v2.1.7
func (*Repo) StagedFiles ¶ added in v2.1.7
StagedFiles returns a list of staged files which exist on file system.
func (*Repo) StagedFilesWithDeleted ¶ added in v2.1.7
StagedFilesWithDeleted returns a list of staged files with deleted files.