Documentation
¶
Overview ¶
Package vcs exposes functions for resolving import paths and using version control systems, which can be used to implement behavior similar to the standard "go get" command.
Index ¶
- Variables
- func IsKnownCodeHost(importPath string) bool
- type Cmd
- func (v *Cmd) Create(dir, repo string) error
- func (v *Cmd) CreateAtRev(dir, repo, rev string) error
- func (v *Cmd) Download(dir string) error
- func (v *Cmd) Log(dir, logTemplate string) ([]byte, error)
- func (v *Cmd) LogAtRev(dir, rev, logTemplate string) ([]byte, error)
- func (v *Cmd) String() string
- func (v *Cmd) TagSync(dir, tag string) error
- func (v *Cmd) Tags(dir string) ([]string, error)
- type RepoRoot
- type TagCmd
Constants ¶
This section is empty.
Variables ¶
var ShowCmd bool
ShowCmd controls whether VCS commands are printed.
var Verbose bool
Verbose enables verbose operation logging.
Functions ¶
func IsKnownCodeHost ¶
IsKnownCodeHost reports whether importPath is on one of the code hosts in vcsPaths, such as github.com. Their repository roots follow from the path itself, so they are never looked up dynamically.
Types ¶
type Cmd ¶
type Cmd struct {
Name string
Cmd string // name of binary to invoke command
CreateCmd string // command to download a fresh copy of a repository
DownloadCmd string // command to download updates into an existing repository
TagCmd []TagCmd // commands to list tags
TagLookupCmd []TagCmd // commands to lookup tags before running tagSyncCmd
TagSyncCmd string // command to sync to specific tag
TagSyncDefault string // command to sync to default tag
LogCmd string // command to list repository changelogs in an XML format
}
A Cmd describes how to use a version control system like Mercurial, Git, or Subversion.
func ByCmd ¶
ByCmd returns the version control system for the given command name (hg, git, svn, bzr).
func FromDir ¶
FromDir inspects dir and its parents to determine the version control system and code repository to use. On return, root is the import path corresponding to the root of the repository.
func (*Cmd) Create ¶
Create creates a new copy of repo in dir. The parent of dir must exist; dir must not.
func (*Cmd) CreateAtRev ¶
CreateAtRev creates a new copy of repo in dir at revision rev. The parent of dir must exist; dir must not. rev must be a valid revision in repo.
func (*Cmd) Download ¶
Download downloads any new changes for the repo in dir. dir must be a valid VCS repo compatible with v.
func (*Cmd) Log ¶
Log logs the changes for the repo in dir. dir must be a valid VCS repo compatible with v.
func (*Cmd) LogAtRev ¶
LogAtRev logs the change for repo in dir at the rev revision. dir must be a valid VCS repo compatible with v. rev must be a valid revision for the repo in dir.
type RepoRoot ¶
type RepoRoot struct {
VCS *Cmd
// Repo is the repository URL, including scheme.
Repo string
// Root is the import path corresponding to the root of the
// repository.
Root string
}
RepoRoot represents a version control system, a repo, and a root of where to put it on disk.
func RepoRootForImportDynamic ¶
RepoRootForImportDynamic finds a *RepoRoot for a custom domain that's not statically known by RepoRootForImportPathStatic.
This handles custom import paths like "name.tld/pkg/foo" or just "name.tld".
func RepoRootForImportPath ¶
RepoRootForImportPath analyzes importPath to determine the version control system, and code repository to use.
func RepoRootForImportPathStatic ¶
RepoRootForImportPathStatic attempts to map importPath to a RepoRoot using the commonly-used VCS hosting sites in vcsPaths (github.com/user/dir), or from a fully-qualified importPath already containing its VCS type (foo.com/repo.git/dir)