git

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEmptyLocalGitDirectory added in v1.1.8

func CreateEmptyLocalGitDirectory() (string, error)

CreateEmptyLocalGitDirectory creates a git directory with no checkin yet

func CreateLocalGitDirectory added in v1.1.8

func CreateLocalGitDirectory() (string, error)

CreateLocalGitDirectory creates a git directory with a commit

func CreateLocalGitDirectoryWithSubmodule added in v1.1.8

func CreateLocalGitDirectoryWithSubmodule() (string, error)

CreateLocalGitDirectoryWithSubmodule creates a git directory with a submodule

func HasGitBinary added in v1.1.8

func HasGitBinary() bool

HasGitBinary checks if the 'git' binary is available on the system

func IsLocalNonBareGitRepository added in v1.1.8

func IsLocalNonBareGitRepository(fs fs.FileSystem, dir string) (bool, error)

IsLocalNonBareGitRepository returns true if dir hosts a non-bare git repository, i.e. it contains a ".git" subdirectory or file (submodule case).

func LocalNonBareGitRepositoryIsEmpty added in v1.1.8

func LocalNonBareGitRepositoryIsEmpty(fs fs.FileSystem, dir string) (bool, error)

LocalNonBareGitRepositoryIsEmpty returns true if the non-bare git repository at dir has no refs or objects. It also handles the case of dir being a checked out git submodule.

Types

type CloneConfig added in v1.1.8

type CloneConfig struct {
	Recursive bool
	Quiet     bool
}

CloneConfig specifies the options used when cloning the application source code.

type Git

type Git interface {
	Clone(source *URL, target string, opts CloneConfig) error
	Checkout(repo, ref string) error
	SubmoduleUpdate(repo string, init, recursive bool) error
	LsTree(repo, ref string, recursive bool) ([]os.FileInfo, error)
	GetInfo(string) *SourceInfo
}

Git is an interface used by main STI code to extract/checkout git repositories

func New

func New(fs fs.FileSystem, runner cmd.CommandRunner) Git

New returns a new instance of the default implementation of the Git interface

type SourceInfo added in v1.1.8

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 URL added in v1.1.8

type URL struct {
	URL  url.URL
	Type URLType
}

URL represents a "Git URL"

func MustParse added in v1.1.8

func MustParse(rawurl string) *URL

MustParse parses a "Git URL" and panics on failure

func Parse added in v1.1.8

func Parse(rawurl string) (*URL, error)

Parse parses a "Git URL"

func (URL) IsLocal added in v1.1.8

func (u URL) IsLocal() bool

IsLocal returns true if the Git URL refers to a local repository

func (URL) LocalPath added in v1.1.8

func (u URL) LocalPath() string

LocalPath returns the path to a local repository in OS-native format. It is assumed that IsLocal() is true

func (URL) String added in v1.1.8

func (u URL) String() string

String returns a string representation of the URL

func (URL) StringNoFragment added in v1.1.8

func (u URL) StringNoFragment() string

StringNoFragment returns a string representation of the URL without its fragment

type URLType added in v1.1.8

type URLType int

URLType indicates the type of the URL (see above)

const (
	// URLTypeURL is the URL type (see above)
	URLTypeURL URLType = iota
	// URLTypeSCP is the SCP type (see above)
	URLTypeSCP
	// URLTypeLocal is the local type (see above)
	URLTypeLocal
)

func (URLType) GoString added in v1.1.8

func (t URLType) GoString() string

GoString returns a Go string representation of the URLType

func (URLType) String added in v1.1.8

func (t URLType) String() string

String returns a string representation of the URLType

Jump to

Keyboard shortcuts

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