git

package
v0.0.0-...-326c0ea Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloner

type Cloner interface {
	Clone(
		ctx context.Context,
		url string,
		dest string,
	) error
}

Cloner is the interface that wraps the Clone method.

Clone clones a remote git repository into a destination path.

type Git

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

Git represents the components reponsible for cloning and opening git repositories. It is supposed to hide the authentication mechanisms used to clone repositories. Git implements OpenCloner interface.

func New

func New(options ...Option) *Git

New instanciate a new Git struct. It take a list of Option objects to configure the remote and/or the authentication method.

func (*Git) Clone

func (g *Git) Clone(ctx context.Context, url, dest string) error

Clone clones a remote git repository into a destination path. Clone will prioritise SSH signer if it's set.

func (*Git) Open

func (g *Git) Open(path string) (*git.Repository, error)

Open opens a git repository from the given path.

type OpenCloner

type OpenCloner interface {
	Opener
	Cloner
}

OpenCloner is the interface that wraps the Open and Clone methods.

type Opener

type Opener interface {
	Open(path string) (*git.Repository, error)
}

Open is the interface that wraps the Open method.

Open opens a git repository from the given path.

type Option

type Option func(*Git)

func WithGithubCredentials

func WithGithubCredentials(username, token string) Option

WithGithubCredentials sets the Github username and password used to clone repositories with HTTPS protocol.

func WithRemote

func WithRemote(remote string) Option

WithRemote sets the remote attached to cloning URL.

func WithSSHSigner

func WithSSHSigner(signer ssh.Signer) Option

WithSSHSigner sets the ssh.Signer used to clone repositories with ssh protocol.

Jump to

Keyboard shortcuts

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