repos

package
v0.0.0-...-a85b63b Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindExternalRepo

func FindExternalRepo(repoRoot, name string) (string, error)

FindExternalRepo attempts to locate the directory where Bazel has fetched the external repository with the given name. An error is returned if the repository directory cannot be located.

func GenerateRule

func GenerateRule(repo Repo) bf.Expr

GenerateRule returns a repository rule for the given repository that can be written in a WORKSPACE file.

func ImportRepoRules

func ImportRepoRules(filename string) ([]bf.Expr, error)

ImportRepoRules reads the lock file of a vendoring tool and returns a list of equivalent repository rules that can be merged into a WORKSPACE file. The format of the file is inferred from its basename. Currently, only Gopkg.lock is supported.

Types

type RemoteCache

type RemoteCache struct {
	// RepoRootForImportPath is vcs.RepoRootForImportPath by default. It may
	// be overridden so that tests may avoid accessing the network.
	RepoRootForImportPath func(string, bool) (*vcs.RepoRoot, error)

	// HeadCmd returns the latest commit on the default branch in the given
	// repository. This is used by Head. It may be stubbed out for tests.
	HeadCmd func(remote, vcs string) (string, error)
	// contains filtered or unexported fields
}

RemoteCache stores information about external repositories. The cache may be initialized with information about known repositories, i.e., those listed in the WORKSPACE file and mentioned on the command line. Other information is retrieved over the network.

Public methods of RemoteCache may be slow in cases where a network fetch is needed. Public methods may be called concurrently.

func NewRemoteCache

func NewRemoteCache(knownRepos []Repo) *RemoteCache

NewRemoteCache creates a new RemoteCache with a set of known repositories. The Root and Remote methods will return information about repositories listed here without accessing the network. However, the Head method will still access the network for these repositories to retrieve information about new versions.

func (*RemoteCache) Head

func (r *RemoteCache) Head(remote, vcs string) (commit, tag string, err error)

Head returns the most recent commit id on the default branch and latest version tag for the given remote repository. The tag "" is returned if no latest version was found.

TODO(jayconrod): support VCS other than git. TODO(jayconrod): support version tags. "" is always returned.

func (*RemoteCache) Remote

func (r *RemoteCache) Remote(root string) (remote, vcs string, err error)

Remote returns the VCS name and the remote URL for a repository with the given root import path. This is suitable for creating new repository rules.

func (*RemoteCache) Root

func (r *RemoteCache) Root(importPath string) (root, name string, err error)

Root returns the portion of an import path that corresponds to the root directory of the repository containing the given import path. For example, given "golang.org/x/tools/go/loader", this will return "golang.org/x/tools". The workspace name of the repository is also returned. This may be a custom name set in WORKSPACE, or it may be a generated name based on the root path.

type Repo

type Repo struct {
	// Name is the value of the "name" attribute of the repository rule.
	Name string

	// GoPrefix is the portion of the Go import path for the root of this
	// repository. Usually the same as Remote.
	GoPrefix string

	// Commit is the revision at which a repository is checked out (for example,
	// a Git commit id).
	Commit string

	// Tag is the name of the version at which a repository is checked out.
	Tag string

	// Remote is the URL the repository can be cloned or checked out from.
	Remote string

	// VCS is the version control system used to check out the repository.
	// May also be "http" for HTTP archives.
	VCS string
}

Repo describes an external repository rule declared in a Bazel WORKSPACE file.

func ListRepositories

func ListRepositories(workspace *bf.File) []Repo

ListRepositories extracts metadata about repositories declared in a WORKSPACE file.

The set of repositories returned is necessarily incomplete, since we don't evaluate the file, and repositories may be declared in macros in other files.

func UpdateRepo

func UpdateRepo(rc *RemoteCache, importPath string) (Repo, error)

UpdateRepo returns an object describing a repository at the most recent commit or version tag.

This function uses RemoteCache to retrieve information about the repository. Depending on how the RemoteCache was initialized and used earlier, some information may already be locally available. Frequently though, information will be fetched over the network, so this function may be slow.

Jump to

Keyboard shortcuts

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