codehost

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: 12 Imported by: 0

Documentation

Overview

Package codehost defines the interface implemented by a code hosting source, along with support code for use by implementations.

Index

Constants

View Source
const (
	MaxGoMod   = 16 << 20  // maximum size of go.mod file
	MaxLICENSE = 16 << 20  // maximum size of LICENSE file
	MaxZipFile = 500 << 20 // maximum size of downloaded zip file
)

Downloaded size limits.

Variables

View Source
var WorkRoot string

WorkRoot is the root of the cached work directory. It is set by cmd/go/internal/vgo.InitMod.

Functions

func AllHex

func AllHex(rev string) bool

AllHex reports whether the revision rev is entirely lower-case hexadecimal digits.

func Run

func Run(dir string, cmdline ...interface{}) ([]byte, error)

Run runs the command line in the given directory (an empty dir means the current directory). It returns the standard output and, for a non-zero exit, a *RunError indicating the command, exit status, and standard error. Standard error is unavailable for commands that exit successfully.

func ShortenSHA1

func ShortenSHA1(rev string) string

ShortenSHA1 shortens a SHA1 hash (40 hex digits) to the canonical length used in pseudo-versions (12 hex digits).

func WorkDir

func WorkDir(typ, name string) (string, error)

WorkDir returns the name of the cached work directory to use for the given repository type and name.

Types

type Repo

type Repo interface {
	// Root returns the import path of the root directory of the repository.
	Root() string

	// List lists all tags with the given prefix.
	Tags(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 implementation.
	Latest() (*RevInfo, error)

	// ReadFile reads the given file in the file tree corresponding to revision rev.
	// It should refuse to read more than maxSize bytes.
	ReadFile(rev, file string, maxSize int64) (data []byte, err error)

	// ReadZip downloads a zip file for the subdir subdirectory
	// of the given revision to a new file in a given temporary directory.
	// It should refuse to read more than maxSize bytes.
	// It returns a ReadCloser for a streamed copy of the zip file,
	// along with the actual subdirectory (possibly shorter than subdir)
	// contained in the zip file. All files in the zip file are expected to be
	// nested in a single top-level directory, whose name is not specified.
	ReadZip(rev, subdir string, maxSize int64) (zip io.ReadCloser, actualSubdir string, err error)
}

A Repo represents a code hosting source. Typical implementations include local version control repositories, remote version control servers, and code hosting sites.

type RevInfo

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

A Rev describes a single revision in a source code repository.

type RunError

type RunError struct {
	Cmd    string
	Err    error
	Stderr []byte
}

func (*RunError) Error

func (e *RunError) Error() string

Jump to

Keyboard shortcuts

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