vendor

package
v0.0.0-...-64bbc4d Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DepPresent       = errors.New("dependency already present")
	DepSubPkgPresent = errors.New("subpackages of this dependency are already present")
	DepMissing       = errors.New("dependency does not exist")
)

Functions

func FetchMetadata

func FetchMetadata(path string, insecure bool) (rc io.ReadCloser, err error)

FetchMetadata fetchs the remote metadata for path.

func ParseImports

func ParseImports(root, vendorRoot, vendorPrefix string, tests, all bool) (map[string]bool, error)

ParseImports parses Go packages from a specific root returning a set of import paths. vendorRoot is how deep to go looking for vendor folders, usually the repo root. vendorPrefix is the vendorRoot import path.

func ParseMetadata

func ParseMetadata(path string, insecure bool) (string, string, string, error)

ParseMetadata fetchs and decodes remote metadata for path.

func WriteManifest

func WriteManifest(path string, m *Manifest) error

WriteManifest writes a Manifest to the path. If the manifest does not exist, it is created. If it does exist, it will be overwritten. If the manifest file is empty (0 dependencies) it will be deleted. The dependencies will be ordered by import path to reduce churn when making changes. TODO(dfc) write to temporary file and move atomically to avoid destroying a working vendorfile.

Types

type BzrClone

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

BzrClone is a bazaar WorkingCopy.

func (*BzrClone) Branch

func (b *BzrClone) Branch() (string, error)

func (*BzrClone) Destroy

func (b *BzrClone) Destroy() error

func (BzrClone) Dir

func (w BzrClone) Dir() string

func (*BzrClone) Revision

func (b *BzrClone) Revision() (string, error)

type Dependency

type Dependency struct {
	// Importpath is name by which this dependency is known.
	Importpath string `json:"importpath"`

	// Repository is the remote DVCS location that this
	// dependency was fetched from.
	Repository string `json:"repository"`

	// VCS is the DVCS system found at Repository.
	VCS string `json:"vcs"`

	// Revision is the revision that describes the dependency's
	// remote revision.
	Revision string `json:"revision"`

	// Branch is the branch the Revision was located on.
	// Can be blank if not needed.
	Branch string `json:"branch"`

	// Path is the path inside the Repository where the
	// dependency was fetched from.
	Path string `json:"path,omitempty"`

	// NoTests indicates that test files were ignored.
	// In the negative for backwards compatibility.
	NoTests bool `json:"notests,omitempty"`

	// AllFiles indicates that no files were ignored.
	AllFiles bool `json:"allfiles,omitempty"`
}

Dependency describes one vendored import path of code A Dependency is an Importpath sources from a Respository at Revision from Path.

type GitClone

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

GitClone is a git WorkingCopy.

func (*GitClone) Branch

func (g *GitClone) Branch() (string, error)

func (GitClone) Destroy

func (w GitClone) Destroy() error

func (GitClone) Dir

func (w GitClone) Dir() string

func (*GitClone) Revision

func (g *GitClone) Revision() (string, error)

type HgClone

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

HgClone is a mercurial WorkingCopy.

func (*HgClone) Branch

func (h *HgClone) Branch() (string, error)

func (HgClone) Destroy

func (w HgClone) Destroy() error

func (HgClone) Dir

func (w HgClone) Dir() string

func (*HgClone) Revision

func (h *HgClone) Revision() (string, error)

type Manifest

type Manifest struct {
	// Manifest version. Current manifest version is 0.
	Version int `json:"version"`

	// Depenencies is a list of vendored dependencies.
	Dependencies []Dependency `json:"dependencies"`
}

Manifest describes the layout of $PROJECT/vendor/manifest.

func ReadManifest

func ReadManifest(path string) (*Manifest, error)

ReadManifest reads a Manifest from path. If the Manifest is not found, a blank Manifest will be returned.

func (*Manifest) AddDependency

func (m *Manifest) AddDependency(dep Dependency) error

AddDependency adds a Dependency to the current Manifest. If the dependency exists already then it returns and error.

func (*Manifest) GetDependencyForImportpath

func (m *Manifest) GetDependencyForImportpath(path string) (Dependency, error)

GetDependencyForRepository return a dependency for specified import path. Note that it might be a parent of the specified path. If the dependency does not exist it returns an error.

func (*Manifest) GetSubpackages

func (m *Manifest) GetSubpackages(path string) (deps []Dependency)

GetSubpackages returns any Dependency in the Manifest that is a subpackage of the given import path.

func (*Manifest) HasImportpath

func (m *Manifest) HasImportpath(path string) bool

HasImportpath reports whether the Manifest contains the import path, or a parent of it.

func (*Manifest) RemoveDependency

func (m *Manifest) RemoveDependency(dep Dependency) error

RemoveDependency removes a Dependency from the current Manifest. If the dependency does not exist then it returns an error.

type RemoteRepo

type RemoteRepo interface {

	// Checkout checks out a specific branch, tag, or revision.
	// The interpretation of these three values is impementation
	// specific.
	Checkout(branch, tag, revision string) (WorkingCopy, error)

	// URL returns the URL the clone was/will be taken from.
	URL() string

	// Type returns the repository type (git, hg, ...)
	Type() string
}

RemoteRepo describes a remote dvcs repository.

func Bzrrepo

func Bzrrepo(url string) (RemoteRepo, error)

Bzrrepo returns a RemoteRepo representing a remote bzr repository.

func DeduceRemoteRepo

func DeduceRemoteRepo(path string, insecure bool) (RemoteRepo, string, error)

DeduceRemoteRepo takes a potential import path and returns a RemoteRepo representing the remote location of the source of an import path. Remote repositories can be bare import paths, or urls including a checkout scheme. If deduction would cause traversal of an insecure host, a message will be printed and the travelsal path will be ignored.

func Gitrepo

func Gitrepo(url *url.URL, insecure bool, schemes ...string) (RemoteRepo, error)

Gitrepo returns a RemoteRepo representing a remote git repository.

func Hgrepo

func Hgrepo(u *url.URL, insecure bool, schemes ...string) (RemoteRepo, error)

Hgrepo returns a RemoteRepo representing a remote git repository.

func NewRemoteRepo

func NewRemoteRepo(repoURL, vcs string, insecure bool) (RemoteRepo, error)

type WorkingCopy

type WorkingCopy interface {

	// Dir is the root of this working copy.
	Dir() string

	// Revision returns the revision of this working copy.
	Revision() (string, error)

	// Branch returns the branch to which this working copy belongs.
	Branch() (string, error)

	// Destroy removes the working copy.
	Destroy() error
}

WorkingCopy represents a local copy of a remote dvcs repository.

Jump to

Keyboard shortcuts

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