modfetch

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: BSD-3-Clause Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPseudoVersion

func IsPseudoVersion(v string) bool

IsPseudoVersion reports whether v is a pseudo-version.

func IsZeroPseudoVersion

func IsZeroPseudoVersion(v string) bool

IsZeroPseudoVersion returns whether v is a pseudo-version with a zero base, timestamp, and revision, as returned by ZeroPseudoVersion.

func PseudoVersion

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

PseudoVersion returns a pseudo-version for the given major version ("v1") preexisting older tagged version ("" or "v1.2.3" or "v1.2.3-pre"), revision time, and revision identifier (usually a 12-byte commit hash prefix).

func PseudoVersionBase

func PseudoVersionBase(v string) (string, error)

PseudoVersionBase returns the canonical parent version, if any, upon which the pseudo-version v is based.

If v has no parent version (that is, if it is "vX.0.0-[…]"), PseudoVersionBase returns the empty string and a nil error.

func PseudoVersionRev

func PseudoVersionRev(v string) (rev string, err error)

PseudoVersionRev returns the revision identifier of the pseudo-version v. It returns an error if v is not a pseudo-version.

func PseudoVersionTime

func PseudoVersionTime(v string) (time.Time, error)

PseudoVersionTime returns the time stamp of the pseudo-version v. It returns an error if v is not a pseudo-version or if the time stamp embedded in the pseudo-version is not a valid time.

func SortVersions

func SortVersions(list []string)

func ZeroPseudoVersion

func ZeroPseudoVersion(major string) string

ZeroPseudoVersion returns a pseudo-version with a zero timestamp and revision, which may be used as a placeholder.

Types

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 returns a non-nil error only if there was a problem
	// fetching the list of versions: it may return an empty list
	// along with a nil error if the list of matching versions
	// is known to be empty.
	//
	// If the underlying repository does not exist,
	// Versions returns an error matching errors.Is(_, os.NotExist).
	Versions(prefix string) ([]string, 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 writes a zip file for the given version to dst.
	Zip(dst io.Writer, version string) error
}

A Repo represents a repository storing all versions of a single module. It must be safe for simultaneous use by multiple goroutines.

func NewCodeRepo

func NewCodeRepo(code codehost.Repo, codeRoot, path string) (Repo, error)

type RevInfo

type RevInfo struct {
	Version string    // suggested version string for this revision
	Time    time.Time // commit time

	// These fields are used for Stat of arbitrary rev,
	// but they are not recorded when talking about module versions.
	Name  string `json:"-"` // complete ID in underlying repository
	Short string `json:"-"` // shortened ID, for use in pseudo-version
}

A Rev describes a single revision in a module repository.

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.

Jump to

Keyboard shortcuts

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