gitutils

package
v0.0.4 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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