git

package
v0.0.0-...-a892dfa Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package git allows working with Git repositories

Index

Constants

View Source
const (

	// Shallow maps to --depth=1, which clones a Git repository without
	// downloading history
	Shallow = "--depth=1"
)

Variables

View Source
var ErrGitNotAvailable = errors.New("git binary not available")

ErrGitNotAvailable will be returned if the git call fails because a git binary could not be found

Functions

func IsBareRoot

func IsBareRoot(path string) (bool, error)

IsRoot returns true if location is the root of a bare git repository

func IsExitCode

func IsExitCode(err error, exitCode int) bool

func IsGitInstalled

func IsGitInstalled() bool

func NameFromRepositoryURL

func NameFromRepositoryURL(url *url.URL) (string, bool)

NameFromRepositoryURL suggests a name for a repository URL based on the last segment of the path, or returns false

Types

type ChangedRef

type ChangedRef struct {
	Ref string
	Old string
	New string
}

func ParsePostReceive

func ParsePostReceive(r io.Reader) ([]ChangedRef, error)

type GitError

type GitError struct {
	Err    error
	Stdout string
	Stderr string
}

GitError is returned when the underlying Git command returns a non-zero exit code.

func (*GitError) Error

func (e *GitError) Error() string

type Repository

type Repository interface {
	GetRootDir(dir string) (string, error)
	GetOriginURL(dir string) (string, bool, error)
	GetRef(dir string) string
	Clone(dir string, url string) error
	CloneWithOptions(dir string, url string, args ...string) error
	CloneBare(dir string, url string) error
	CloneMirror(dir string, url string) error
	Fetch(dir string, url string, ref string) error
	Checkout(dir string, ref string) error
	PotentialPRRetryAsFetch(dir string, url string, ref string, err error) error
	SubmoduleUpdate(dir string, init, recursive bool) error
	Archive(dir, ref, format string, w io.Writer) error
	Init(dir string, bare bool) error
	Add(dir string, spec string) error
	Commit(dir string, message string) error
	AddRemote(dir string, name, url string) error
	AddLocalConfig(dir, name, value string) error
	ShowFormat(dir, commit, format string) (string, error)
	ListRemote(url string, args ...string) (string, string, error)
	TimedListRemote(timeout time.Duration, url string, args ...string) (string, string, error)
	GetInfo(location string) (*SourceInfo, []error)
}

Repository represents a git source repository

func NewRepository

func NewRepository() Repository

NewRepository creates a new Repository

func NewRepositoryForBinary

func NewRepositoryForBinary(gitBinaryPath string) Repository

NewRepositoryForBinary returns a Repository using the specified git executable.

func NewRepositoryForBinaryWithEnvironment

func NewRepositoryForBinaryWithEnvironment(gitBinaryPath string, env []string) Repository

NewRepositoryForBinary returns a Repository using the specified git executable and environment

func NewRepositoryWithEnv

func NewRepositoryWithEnv(env []string) Repository

NewRepositoryForEnv creates a new Repository using the specified environment

type SourceInfo

type SourceInfo struct {
	// Ref represents a commit SHA-1, valid Git branch name or a Git tag
	// The output image will contain this information as 'io.openshift.build.commit.ref' label.
	Ref string

	// CommitID represents an arbitrary extended object reference in Git as SHA-1
	// The output image will contain this information as 'io.openshift.build.commit.id' label.
	CommitID string

	// Date contains a date when the committer created the commit.
	// The output image will contain this information as 'io.openshift.build.commit.date' label.
	Date string

	// AuthorName contains the name of the author
	// The output image will contain this information (along with AuthorEmail) as 'io.openshift.build.commit.author' label.
	AuthorName string

	// AuthorEmail contains the e-mail of the author
	// The output image will contain this information (along with AuthorName) as 'io.openshift.build.commit.author' lablel.
	AuthorEmail string

	// CommitterName contains the name of the committer
	CommitterName string

	// CommitterEmail contains the e-mail of the committer
	CommitterEmail string

	// Message represents the first 80 characters from the commit message.
	// The output image will contain this information as 'io.openshift.build.commit.message' label.
	Message string

	// Location contains a valid URL to the original repository.
	// The output image will contain this information as 'io.openshift.build.source-location' label.
	Location string

	// ContextDir contains path inside the Location directory that
	// contains the application source code.
	// The output image will contain this information as 'io.openshift.build.source-context-dir'
	// label.
	ContextDir string
}

SourceInfo stores information about the source code

type TimeoutError

type TimeoutError struct {
	Err error
}

TimeoutError is returned when the underlying Git coommand times out before finishing

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

Jump to

Keyboard shortcuts

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