git

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGitURL

func IsGitURL(rawURL string) bool

IsGitURL returns true if the argument matches the git url format

func RepoName

func RepoName(repoURL string) (string, error)

RepoName returns the name of the repository given its URL

func ValidateURL

func ValidateURL(url string) error

ValidateURL validates the provided Git URL.

Types

type Client

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

Client can perform git operations on the given directory

func NewGitClient

func NewGitClient(params ClientParams) *Client

NewGitClient returns a client that can perform git operations

func NewGitClientFromExecutor

func NewGitClientFromExecutor(executor executor.Executor) *Client

NewGitClientFromExecutor returns a client that can have an executor injected. Useful for testing

func (Client) Add

func (git Client) Add(files ...string) error

Add performs can perform a `git add` operation on the given file paths

func (*Client) CloneRepoInPath

func (git *Client) CloneRepoInPath(clonePath string, options CloneOptions) error

CloneRepoInPath behaves like CloneRepoInTmpDir but clones the repository in a specific directory which creates if needed

func (*Client) CloneRepoInTmpDir

func (git *Client) CloneRepoInTmpDir(tmpDirPrefix string, options CloneOptions) (string, error)

CloneRepoInTmpDir clones a repo specified in the gitURL in a temporary directory and checks out the specified branch

func (Client) Commit

func (git Client) Commit(message, user, email string) error

Commit makes a commit if there are staged changes

func (Client) DeleteLocalRepo

func (git Client) DeleteLocalRepo() error

DeleteLocalRepo deletes the local copy of a repository, including the directory

func (Client) Push

func (git Client) Push() error

Push pushes the changes to the origin remote

type ClientParams

type ClientParams struct {
	PrivateSSHKeyPath string
}

ClientParams groups the arguments to provide to create a new Git client.

type CloneOptions

type CloneOptions struct {
	URL       string
	Branch    string
	Bootstrap bool // create the branch if the repository is empty
}

CloneOptions are the options for cloning a Git repository

type Options

type Options struct {
	URL               string
	Branch            string
	User              string
	Email             string
	PrivateSSHKeyPath string
}

Options holds options to interact with a Git repository.

func (Options) Validate

func (o Options) Validate() error

Validate validates this Options object.

func (Options) ValidateEmail

func (o Options) ValidateEmail() error

ValidateEmail validates the email field of this Options object, return an error should the current value not be valid.

func (Options) ValidatePrivateSSHKeyPath

func (o Options) ValidatePrivateSSHKeyPath() error

ValidatePrivateSSHKeyPath validates the path to the (optional) private SSH key used to interact with the Git repository configured in this object.

func (Options) ValidateURL

func (o Options) ValidateURL() error

ValidateURL validates the URL field of this Options object, returning an error should the current value not be valid.

type TmpCloner

type TmpCloner interface {
	CloneRepoInTmpDir(cloneDirPrefix string, options CloneOptions) (string, error)
}

TmpCloner can clone git repositories in temporary directories

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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