repo

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2014 License: BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatXRefs is the number of external references to any def defined in a
	// repository (i.e., references from other repositories). It is only
	// computed per-repository (and not per-repository-commit) because it is
	// not easy to determine which specific commit a ref references.
	StatXRefs = "xrefs"

	// StatAuthors is the number of resolved people who contributed code to any
	// def defined in a repository (i.e., references from other
	// repositories). It is only computed per-repository-commit.
	StatAuthors = "authors"

	// StatClients is the number of resolved people who have committed refs that
	// reference a def defined in the repository. It is only computed
	// per-repository (and not per-repository-commit) because it is not easy to
	// determine which specific commit a ref references.
	StatClients = "clients"

	// StatDependencies is the number of repositories that the repository
	// depends on. It is only computed per-repository-commit.
	StatDependencies = "dependencies"

	// StatDependents is the number of repositories containing refs to a def
	// defined in the repository. It is only computed per-repository (and not
	// per-repository-commit) because it is not easy to determine which specific
	// commit a ref references.
	StatDependents = "dependents"

	// StatDefs is the number of defs defined in a repository commit. It
	// is only computed per-repository-commit (or else it would count 1 def
	// for each revision of the repository that we have processed).
	StatDefs = "defs"

	// StatExportedDefs is the number of exported defs defined in a
	// repository commit. It is only computed per-repository-commit (or else it
	// would count 1 def for each revision of the repository that we have
	// processed).
	StatExportedDefs = "exported-defs"
)

Variables

View Source
var ErrForbidden = errors.New("repository is unavailable")

ErrForbidden is an error indicating that the repository can no longer be accessed due to server's refusal to serve it (possibly DMCA takedowns on github etc)

View Source
var ErrNoScheme = errors.New("clone URL has no scheme")

ErrNoScheme is an error indicating that a clone URL contained no scheme component (e.g., "http://").

View Source
var ErrNotExist = errors.New("repository does not exist on external host")

ErrNotExist is an error definitively indicating that no such repository exists.

View Source
var ErrNotPersisted = errors.New("repository is not persisted locally, but it might exist remotely (explicitly add it to check)")

ErrNotPersisted is an error indicating that no such repository is persisted locally. The repository might exist on a remote host, but it must be explicitly added (it will not be implicitly added via a Get call).

View Source
var ExternalHostTimeout = time.Second * 7

ExternalHostTimeout is the timeout for HTTP requests to external repository hosts.

View Source
var StatTypes = map[StatType]struct{}{StatXRefs: struct{}{}, StatAuthors: struct{}{}, StatClients: struct{}{}, StatDependencies: struct{}{}, StatDependents: struct{}{}, StatDefs: struct{}{}, StatExportedDefs: struct{}{}}

Functions

func IsForbidden

func IsForbidden(err error) bool

func IsNotPresent

func IsNotPresent(err error) bool

IsNotPresent returns whether err is one of ErrNotExist, ErrNotPersisted, or ErrRedirected.

func MapByURI

func MapByURI(repos []*Repository) map[URI]*Repository

func URIEqual

func URIEqual(a, b URI) bool

URIEqual returns true if a and b are equal, based on a case insensitive comparison.

Types

type ErrRenamed

type ErrRenamed struct {
	// OldURI is the previous repository URI.
	OldURI URI

	// NewURI is the new URI that the repository was renamed to.
	NewURI URI
}

ErrRenamed is an error type that indicates that a repository was renamed from OldURI to NewURI.

func (ErrRenamed) Error

func (e ErrRenamed) Error() string

type RID

type RID int

RID is the numeric primary key for a repository.

type Repositories

type Repositories []*Repository

func (Repositories) URIs

func (rs Repositories) URIs() (uris []URI)

type Repository

type Repository struct {
	// RID is the numeric primary key for a repository.
	RID RID

	// URI is a normalized identifier for this repository based on its primary
	// clone URL. E.g., "github.com/user/repo".
	URI URI

	// Name is the base name (the final path component) of the repository,
	// typically the name of the directory that the repository would be cloned
	// into. (For example, for git://example.com/foo.git, the name is "foo".)
	Name string

	// OwnerUserID is the account that owns this repository.
	OwnerUserID person.UID `db:"owner_user_id"`

	// OwnerGitHubUserID is the GitHub user ID of this repository's owner, if this
	// is a GitHub repository.
	OwnerGitHubUserID nnz.Int `db:"owner_github_user_id" json:",omitempty"`

	// Description is a brief description of the repository.
	Description string `json:",omitempty"`

	// VCS is the short name of the VCS system that this repository uses: "git"
	// or "hg".
	VCS VCS `db:"vcs"`

	// CloneURL is the URL used to clone the repository from its original host.
	CloneURL string `db:"clone_url"`

	// HomepageURL is the URL to the repository's homepage, if any.
	HomepageURL nnz.String `db:"homepage_url"`

	// DefaultBranch is the default VCS branch used (typically "master" for git
	// repositories and "default" for hg repositories).
	DefaultBranch string `db:"default_branch"`

	// Language is the primary programming language used in this repository.
	Language string

	// GitHubStars is the number of stargazers this repository has on GitHub (or
	// 0 if it is not a GitHub repository).
	GitHubStars int `db:"github_stars"`

	// GitHubID is the GitHub ID of this repository. If a GitHub repository is
	// renamed, the ID remains the same and should be used to resolve across the
	// name change.
	GitHubID nnz.Int `db:"github_id" json:",omitempty"`

	// Disabled is whether this repo should not be downloaded and processed by the worker.
	Disabled bool `json:",omitempty"`

	// Deprecated repositories are labeled as such and hidden from global search results.
	Deprecated bool

	// Fork is whether this repository is a fork.
	Fork bool

	// Mirror is whether this repository is a mirror.
	Mirror bool
}

func (*Repository) IsGitHubRepository

func (r *Repository) IsGitHubRepository() bool

IsGitHubRepository returns true iff this repository is hosted on GitHub.

type StatType

type StatType string

StatType is the name of a repository statistic (see below for a listing).

func (*StatType) Scan

func (x *StatType) Scan(v interface{}) error

Scan implements database/sql.Scanner.

func (StatType) Value

func (x StatType) Value() (driver.Value, error)

Value implements database/sql/driver.Valuer.

type Stats

type Stats map[StatType]int

Stats holds statistics for a repository.

type URI

type URI string

URI identifies a repository.

func MakeURI

func MakeURI(cloneURL string) URI

MakeURI converts a repository clone URL, such as "git://github.com/user/repo.git", to a normalized URI string, such as "github.com/user/repo".

func (URI) GitHubURL

func (u URI) GitHubURL() string

GitHubURL returns the https://github.com/USER/REPO URL for this repository.

func (URI) IsGitHubRepository

func (u URI) IsGitHubRepository() bool

IsGitHubRepository returns true iff this repository is hosted on GitHub.

func (URI) IsGoogleCodeRepository

func (u URI) IsGoogleCodeRepository() bool

IsGoogleCodeRepository returns true iff this repository is hosted on Google Code (code.google.com).

func (*URI) Scan

func (u *URI) Scan(v interface{}) error

Scan implements database/sql.Scanner.

func (URI) Value

func (u URI) Value() (driver.Value, error)

Value implements database/sql/driver.Valuer

type URIs

type URIs []URI

URIs is a wrapper type for a slice of URIs.

func (URIs) Strings

func (us URIs) Strings() []string

Strings returns the URIs as strings.

type VCS

type VCS string
const (
	Git VCS = "git"
	Hg  VCS = "hg"
)

func (*VCS) Scan

func (x *VCS) Scan(v interface{}) error

Scan implements database/sql.Scanner.

func (VCS) Value

func (x VCS) Value() (driver.Value, error)

Value implements database/sql/driver.Valuer

Jump to

Keyboard shortcuts

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