git

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 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

func CreateEmptyLocalGitDirectory() (string, error)

CreateEmptyLocalGitDirectory creates a git directory with no checkin yet

func CreateLocalGitDirectory

func CreateLocalGitDirectory() (string, error)

CreateLocalGitDirectory creates a git directory with a commit

func CreateLocalGitDirectoryWithSubmodule

func CreateLocalGitDirectoryWithSubmodule() (string, error)

CreateLocalGitDirectoryWithSubmodule creates a git directory with a submodule

func HasGitBinary

func HasGitBinary() bool

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

func IsLocalNonBareGitRepository

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

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

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

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

	// Binary file name.
	BinaryName string
	// Binary file size.
	BinarySize uint64
}

SourceInfo stores information about the source code

type URL

type URL struct {
	URL  url.URL
	Type URLType
}

URL represents a "Git URL"

func MustParse

func MustParse(rawurl string) *URL

MustParse parses a "Git URL" and panics on failure

func Parse

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

Parse parses a "Git URL"

func (URL) IsLocal

func (u URL) IsLocal() bool

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

func (URL) LocalPath

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

func (u URL) String() string

String returns a string representation of the URL

func (URL) StringNoFragment

func (u URL) StringNoFragment() string

StringNoFragment returns a string representation of the URL without its fragment

type URLType

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
	// URLTypeBinary is the URL to download file
	URLTypeBinary
)

func (URLType) GoString

func (t URLType) GoString() string

GoString returns a Go string representation of the URLType

func (URLType) String

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