git

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2018 License: Apache-2.0 Imports: 9 Imported by: 158

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGitCommandEnvAndURL

func GetGitCommandEnvAndURL(repo, username, password string, sshPrivateKey string) (string, []string, error)

GetGitCommandOptions returns URL and env options for git operation

func IsSshURL

func IsSshURL(url string) bool

IsSshURL returns true is supplied URL is SSH URL

func NormalizeGitURL

func NormalizeGitURL(repo string) string

NormalizeGitURL normalizes a git URL for lookup and storage

func TestRepo

func TestRepo(repo, username, password string, sshPrivateKey string) error

TestRepo tests if a repo exists and is accessible with the given credentials

Types

type Client

type Client interface {
	CloneOrFetch(url string, username string, password string, sshPrivateKey string, repoPath string) error
	Checkout(repoPath string, sha string) (string, error)
	CommitSHA(repoPath string) (string, error)
	Reset(repoPath string) error
}

Client is a generic git client interface

func NewNativeGitClient

func NewNativeGitClient() (Client, error)

NewNativeGitClient creates new instance of NativeGitClient

type NativeGitClient

type NativeGitClient struct{}

NativeGitClient implements Client interface using git CLI

func (*NativeGitClient) Checkout

func (m *NativeGitClient) Checkout(repoPath string, revision string) (string, error)

Checkout checkout specified git sha

func (*NativeGitClient) CloneOrFetch

func (m *NativeGitClient) CloneOrFetch(repo string, username string, password string, sshPrivateKey string, repoPath string) error

CloneOrFetch either clone or fetch repository into specified directory path.

func (*NativeGitClient) CommitSHA added in v0.3.0

func (m *NativeGitClient) CommitSHA(repoPath string) (string, error)

CommitSHA returns current commit sha from `git rev-parse HEAD`

func (*NativeGitClient) Init added in v0.3.2

func (m *NativeGitClient) Init(repo string, repoPath string) error

Init initializes a local git repository and sets the remote origin

func (*NativeGitClient) Reset

func (m *NativeGitClient) Reset(repoPath string) error

Reset resets local changes in a repository

func (*NativeGitClient) SetCredentials added in v0.3.2

func (m *NativeGitClient) SetCredentials(repo string, username string, password string, sshPrivateKey string, repoPath string) error

SetCredentials sets a local credentials file to connect to a remote git repository

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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