vcs

package module
v0.1.0-deprecated Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: BSD-3-Clause Imports: 16 Imported by: 394

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.

Deprecated: Use the go list command with -json flag instead, which implements up-to-date import path resolution behavior, module support, and includes the latest security fixes.

This package was a copy of internal code in package cmd/go/internal/get before module support, modified to make the identifiers exported. It was provided here for developers who wanted to write tools with similar semantics. It needed to be manually kept in sync with upstream when changes were made to cmd/go/internal/get, as tracked in go.dev/issue/11490. By now, it has diverged significantly from upstream cmd/go/internal/get behavior and will not receive any further updates.

Index

Constants

This section is empty.

Variables

View Source
var ShowCmd bool

ShowCmd controls whether VCS commands are printed.

View Source
var Verbose bool

Verbose enables verbose operation logging.

Functions

This section is empty.

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

	Scheme  []string
	PingCmd string
}

A Cmd describes how to use a version control system like Mercurial, Git, or Subversion.

func ByCmd

func ByCmd(cmd string) *Cmd

ByCmd returns the version control system for the given command name (hg, git, svn, bzr).

func FromDir

func FromDir(dir, srcRoot string) (vcs *Cmd, root string, err error)

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

func (v *Cmd) Create(dir, repo string) error

Create creates a new copy of repo in dir. The parent of dir must exist; dir must not.

func (*Cmd) CreateAtRev

func (v *Cmd) CreateAtRev(dir, repo, rev string) error

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

func (v *Cmd) Download(dir string) error

Download downloads any new changes for the repo in dir. dir must be a valid VCS repo compatible with v.

func (*Cmd) Log

func (v *Cmd) Log(dir, logTemplate string) ([]byte, error)

Log logs the changes for the repo in dir. dir must be a valid VCS repo compatible with v.

func (*Cmd) LogAtRev

func (v *Cmd) LogAtRev(dir, rev, logTemplate string) ([]byte, error)

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.

func (*Cmd) Ping

func (v *Cmd) Ping(scheme, repo string) error

Ping pings the repo to determine if scheme used is valid. This repo must be pingable with this scheme and VCS.

func (*Cmd) String

func (v *Cmd) String() string

func (*Cmd) TagSync

func (v *Cmd) TagSync(dir, tag string) error

TagSync syncs the repo in dir to the named tag, which is either a tag returned by Tags or the empty string (the default tag). dir must be a valid VCS repo compatible with v and the tag must exist.

func (*Cmd) Tags

func (v *Cmd) Tags(dir string) ([]string, error)

Tags returns the list of available tags for the repo in dir. dir must be a valid VCS repo compatible with v.

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, 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, verbose bool) (*RepoRoot, error)

RepoRootForImportPath analyzes importPath to determine the version control system, and code repository to use.

func RepoRootForImportPathStatic

func RepoRootForImportPathStatic(importPath, scheme string) (*RepoRoot, error)

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)

If scheme is non-empty, that scheme is forced.

type TagCmd

type TagCmd struct {
	Cmd     string // command to list tags
	Pattern string // regexp to extract tags from list
}

A TagCmd describes a command to list available tags that can be passed to Cmd.TagSyncCmd.

Jump to

Keyboard shortcuts

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