Documentation ¶
Overview ¶
Package vcs provides methods for VCS.
Index ¶
- Constants
- Variables
- func HTTPSorHTTP(importPath string, security securityMode, verbose bool) (urlStr string, body io.ReadCloser, err error)
- type Cmd
- func (c *Cmd) Create(dir, repo string) error
- func (c *Cmd) CreateAtRev(dir, repo, rev string) error
- func (c *Cmd) Download(dir string, verbose bool) error
- func (c *Cmd) Ping(scheme, repo string) error
- func (c *Cmd) String() string
- func (c *Cmd) TagSync(dir, tag string) error
- func (c *Cmd) Tags(dir string) ([]string, error)
- type MetaImport
- type RepoRoot
- func RepoRootForImportDynamic(importPath string, security securityMode, verbose bool) (*RepoRoot, error)
- func RepoRootForImportPath(importPath string, security securityMode, verbose bool) (*RepoRoot, error)
- func RepoRootFromVCSPaths(importPath, scheme string, security securityMode, vcsPaths []*vcsPath) (*RepoRoot, error)
- type TagCmd
Constants ¶
const ( Secure securityMode = iota Insecure )
Security mode options
Variables ¶
var Bzr = &Cmd{ Name: "Bazaar", Cmd: "bzr", CreateCmd: []string{"branch {repo} {dir}"}, DownloadCmd: []string{"pull --overwrite"}, TagCmd: []TagCmd{{"tags", `^(\S+)`}}, TagSyncCmd: "update -r {tag}", TagSyncDefault: "update -r revno:-1", Scheme: []string{"https", "http", "bzr", "bzr+ssh"}, PingCmd: "info {scheme}://{repo}", RemoteRepo: bzrRemoteRepo, ResolveRepo: bzrResolveRepo, }
Bzr describes how to use Bazaar.
var Git = &Cmd{ Name: "Git", Cmd: "git", CreateCmd: []string{"clone {repo} {dir}", "-go-internal-cd {dir} submodule update --init --recursive"}, DownloadCmd: []string{"pull --ff-only", "submodule update --init --recursive"}, TagCmd: []TagCmd{ {"show-ref", `(?:tags|origin)/(\S+)$`}, }, TagLookupCmd: []TagCmd{ {"show-ref tags/{tag} origin/{tag}", `((?:tags|origin)/\S+)$`}, }, TagSyncCmd: "checkout {tag}", TagSyncDefault: "checkout master", Scheme: []string{"git", "https", "http", "git+ssh", "ssh"}, PingCmd: "ls-remote {scheme}://{repo}", RemoteRepo: gitRemoteRepo, }
Git describes how to use Git.
var Hg = &Cmd{ Name: "Mercurial", Cmd: "hg", CreateCmd: []string{"clone -U {repo} {dir}"}, DownloadCmd: []string{"pull"}, TagCmd: []TagCmd{ {"tags", `^(\S+)`}, {"branches", `^(\S+)`}, }, TagSyncCmd: "update -r {tag}", TagSyncDefault: "update default", Scheme: []string{"https", "http", "ssh"}, PingCmd: "identify {scheme}://{repo}", RemoteRepo: hgRemoteRepo, }
Hg describes how to use Mercurial.
List lists the known version control systems
var ShowCmd bool
ShowCmd controls whether VCS commands are printed.
var Svn = &Cmd{ Name: "Subversion", Cmd: "svn", CreateCmd: []string{"checkout {repo} {dir}"}, DownloadCmd: []string{"update"}, Scheme: []string{"https", "http", "svn", "svn+ssh"}, PingCmd: "info {scheme}://{repo}", RemoteRepo: svnRemoteRepo, }
Svn describes how to use Subversion.
var Verbose bool
Verbose enables verbose operation logging.
Functions ¶
func HTTPSorHTTP ¶
func HTTPSorHTTP(importPath string, security securityMode, verbose bool) (urlStr string, body io.ReadCloser, err error)
HTTPSorHTTP returns the body of either the importPath's https resource or, if unavailable, the http resource.
Types ¶
type Cmd ¶
type Cmd struct { Name string Cmd string // name of binary to invoke command CreateCmd []string // commands to download a fresh copy of a repository DownloadCmd []string // commands to download updates into an existing repository TagCmd []TagCmd // commands to list tags TagLookupCmd []TagCmd // commands to lookup tags before running tagSyncCmd TagSyncCmd string // commands to sync to specific tag TagSyncDefault string // commands to sync to default tag Scheme []string PingCmd string RemoteRepo func(v *Cmd, rootDir string) (remoteRepo string, err error) ResolveRepo func(v *Cmd, rootDir, remoteRepo string) (realRepo string, err error) }
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 (thus root is a prefix of importPath).
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.
type MetaImport ¶
type MetaImport struct {
Prefix, VCS, RepoRoot string
}
MetaImport represents the parsed <meta name="go-import" content="prefix vcs reporoot" /> tags from HTML files.
func MetaImportsForPrefix ¶
func MetaImportsForPrefix(importPrefix string, security securityMode, verbose bool) (urlStr string, imports []MetaImport, err error)
MetaImportsForPrefix takes a package's root import path as declared in a <meta> tag and returns its HTML discovery URL and the parsed metaImport lines found on the page.
The importPath is of the form "golang.org/x/tools". It is an error if no imports are found. urlStr will still be valid if err != nil. The returned urlStr will be of the form "https://golang.org/x/tools?go-get=1"
func ParseMetaGoImports ¶
func ParseMetaGoImports(r io.Reader) (imports []MetaImport, err error)
ParseMetaGoImports returns meta imports from the HTML in r. Parsing ends at the end of the <head> section or the beginning of the <body>.
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 ¶
func RepoRootForImportDynamic(importPath string, security securityMode, verbose bool) (*RepoRoot, error)
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 ¶
func RepoRootForImportPath(importPath string, security securityMode, verbose bool) (*RepoRoot, error)
RepoRootForImportPath analyzes importPath to determine the version control system, and code repository to use.
func RepoRootFromVCSPaths ¶
func RepoRootFromVCSPaths(importPath, scheme string, security securityMode, vcsPaths []*vcsPath) (*RepoRoot, error)
RepoRootFromVCSPaths attempts to map importPath to a repoRoot using the mappings defined in vcsPaths. If scheme is non-empty, that scheme is forced.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
singleflight
Package singleflight provides a duplicate function call suppression mechanism.
|
Package singleflight provides a duplicate function call suppression mechanism. |