modfetch

package standard library
go1.11beta1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotPseudoVersion = errors.New("not a pseudo-version")

Functions

func ConvertLegacyConfig

func ConvertLegacyConfig(f *modfile.File, file string, data []byte) error

ConvertLegacyConfig converts legacy config to modfile. The file argument is slash-delimited.

func Import

func Import(path string, allowed func(module.Version) bool) (Repo, *RevInfo, error)

func PseudoVersion

func PseudoVersion(major string, t time.Time, rev string) string

func SortVersions

func SortVersions(list []string)

func Unzip

func Unzip(dir, zipfile, prefix string, maxSize int64) error

Types

type ModuleSubdirError

type ModuleSubdirError struct {
	ModulePath string
}

func (*ModuleSubdirError) Error

func (e *ModuleSubdirError) Error() string

type Repo

type Repo interface {
	// ModulePath returns the module path.
	ModulePath() string

	// Versions lists all known versions with the given prefix.
	// Pseudo-versions are not included.
	// Versions should be returned sorted in semver order
	// (implementations can use SortVersions).
	Versions(prefix string) (tags []string, err error)

	// Stat returns information about the revision rev.
	// A revision can be any identifier known to the underlying service:
	// commit hash, branch, tag, and so on.
	Stat(rev string) (*RevInfo, error)

	// Latest returns the latest revision on the default branch,
	// whatever that means in the underlying source code repository.
	// It is only used when there are no tagged versions.
	Latest() (*RevInfo, error)

	// GoMod returns the go.mod file for the given version.
	GoMod(version string) (data []byte, err error)

	// Zip downloads a zip file for the given version
	// to a new file in a given temporary directory.
	// It returns the name of the new file.
	// The caller should remove the file when finished with it.
	Zip(version, tmpdir string) (tmpfile string, err error)
}

A Repo represents a repository storing all versions of a single module.

func Lookup

func Lookup(path string) (Repo, error)

Lookup returns the module with the given module path.

type RevInfo

type RevInfo struct {
	Version string    // version string
	Name    string    // complete ID in underlying repository
	Short   string    // shortened ID, for use in pseudo-version
	Time    time.Time // commit time
}

A Rev describes a single revision in a module repository.

func Query

func Query(path, vers string, allowed func(module.Version) bool) (*RevInfo, error)

Query looks up a revision of a given module given a version query string. The module must be a complete module path. The version must take one of the following forms:

  • the literal string "latest", denoting the latest available tagged version
  • v1.2.3, a semantic version string
  • v1 or v1.2, an abbreviated semantic version string completed by adding zeroes (v1.0.0 or v1.2.0);
  • >v1.2.3, denoting the earliest available version after v1.2.3
  • <v1.2.3, denoting the latest available version before v1.2.3
  • an RFC 3339 time stamp, denoting the latest available version at that time
  • a Unix time expressed as seconds since 1970, denoting the latest available version at that time
  • a repository commit identifier, denoting that version

The time stamps can be followed by an optional @branch suffix to limit the result to revisions on a particular branch name.

Directories

Path Synopsis
Package codehost defines the interface implemented by a code hosting source, along with support code for use by implementations.
Package codehost defines the interface implemented by a code hosting source, along with support code for use by implementations.
Package gitrepo provides a Git-based implementation of codehost.Repo.
Package gitrepo provides a Git-based implementation of codehost.Repo.

Jump to

Keyboard shortcuts

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