gitutils

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRepoAlreadyCloned error = errors.New("Repository already cloned")

Functions

func Cloned

func Cloned(dir string) bool

Cloned checks if a path contains a .git directory

Types

type GitUtils

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

func NewGitUtils

func NewGitUtils(useSSHAgent bool, privKeyPath string) (*GitUtils, error)

func (*GitUtils) CloneToDisk

func (gu *GitUtils) CloneToDisk(ctx context.Context, httpsURL, sshURL, path string, progress io.Writer) (string, error)

CloneToDisk clones a repository to a path on disk. The repository is cloned first to a temporary path, and then renamed to the desired path. The function guarantees that if `path` exists, it contains a fully cloned repository. If an authentication method has been configured, the repository is cloned using sshURL, otherwise it is cloned using httpsURL. The progress of the clone operation is streamed to the progress io.Writer

type Repository

type Repository struct {
	GitURL         string
	Path           string
	HeadRefName    string
	HeadRef        string
	LastCommitInfo commitInfo
}

func ReadRepository

func ReadRepository(path string) (*Repository, error)

func (*Repository) LastCommit

func (r *Repository) LastCommit() string

func (*Repository) String

func (r *Repository) String() string

Jump to

Keyboard shortcuts

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