source

package
v0.0.0-...-129ea14 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Branch defines a branch type
	Branch = RefType(iota)

	// Version is a version tag
	Version
)

Variables

View Source
var (
	// ErrURLParse happens when failing to parse the remote as a url
	ErrURLParse = errors.New("error parsing remote git source url")

	// ErrOpenRepo happens when you try to open a repo on disk and it doesnt exist
	ErrOpenRepo = errors.New("error opening repository on disk")

	// ErrCloneRemote happens when you try to clone a repo and something fails
	ErrCloneRemote = errors.New("error cloning repository")

	// ErrFetchRemote happens when trying to fetch the remote
	ErrFetchRemote = errors.New("error fetching the remote")

	// ErrMakeWorkTreeTmpDir happens when trying to create the work tree directory for the temp work tree
	ErrMakeWorkTreeTmpDir = errors.New("error creating the work tree directory")

	// ErrCleanWorkTreeTmpDir happens when you can't clean the work tree from disk
	ErrCleanWorkTreeTmpDir = errors.New("error removing the work tree directory")

	// ErrMakeSrcTree happens when you fail to create the directory for the remote source tree cache
	ErrMakeSrcTree = errors.New("error creating the remote source tree directory")

	// ErrOpenWorkTree happens when trying to open the git work tree
	ErrOpenWorkTree = errors.New("error opening the git work tree")

	// ErrUnknownRefType happens when the ref type is unknown
	ErrUnknownRefType = errors.New("ref type unknown")

	// ErrFindingBranch happens when the branch cannot be found
	ErrFindingBranch = errors.New("error finding branch")

	// ErrCheckLocalRepo happens when the local repository cannot be resolved
	ErrCheckLocalRepo = errors.New("error checking local repository")

	// TmpWorkDir represents the directory used to checkout the work tree
	TmpWorkDir = path.Join(os.TempDir(), "protogen")
)
View Source
var (
	// WorkDir is the dictionary in which we operate
	WorkDir string
)

Functions

This section is empty.

Types

type GitRepo

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

GitRepo represents a worktree

func (*GitRepo) Checkout

func (gr *GitRepo) Checkout(ref Ref) error

Checkout will checkout the repository

func (*GitRepo) Clean

func (gr *GitRepo) Clean() error

Clean cleans the repo work tree from disk

type GitSource

type GitSource struct {
	// Remote represents the git remote
	Remote *url.URL

	// Repo represents the location of the current repository content
	Repo string

	// Three represents the git tree, normally the .git directory
	Tree string
}

GitSource represents a git source

func NewLocalGitSource

func NewLocalGitSource(p string) (*GitSource, error)

NewLocalGitSource initialises a new git source

func NewMockGitSource

func NewMockGitSource(p string) *GitSource

NewMockGitSource returns a local mock source

func NewRemoteGitSource

func NewRemoteGitSource(remote string) (*GitSource, error)

NewRemoteGitSource initialises a new git source

func (*GitSource) InitRepo

func (gs *GitSource) InitRepo() (Repo, error)

InitRepo initialises a git repo

func (*GitSource) PathTo

func (gs *GitSource) PathTo(pkg string) string

PathTo returns the path to a package on the source

func (*GitSource) Root

func (gs *GitSource) Root() string

Root returns the root path for importing dependent packages

type MockRepo

type MockRepo struct{}

MockRepo represents a no-op collection of methods to satisfy the repo interface

func (*MockRepo) Checkout

func (s *MockRepo) Checkout(ref Ref) error

Checkout is a no-op

func (*MockRepo) Clean

func (s *MockRepo) Clean() error

Clean is a no-op

type Ref

type Ref struct {
	Type RefType
	Name string
}

Ref defines the source variant

type RefType

type RefType int

RefType is a type of reference

type Repo

type Repo interface {
	Clean() error
	Checkout(ref Ref) error
}

Repo defines behaviour for a git repository

type Source

type Source interface {
	Root() string
	PathTo(pkg string) string
	InitRepo() (Repo, error)
}

Source defines behaviour for a source

Jump to

Keyboard shortcuts

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