Categorygithub.com/Masterminds/vcs
modulepackage
1.13.3
Repository: https://github.com/masterminds/vcs.git
Documentation: pkg.go.dev

# README

VCS Repository Management for Go

Manage repos in varying version control systems with ease through a common interface.

Linux Tests Go Report Card Windows Tests Docs

Note: Module names are case sensitive. Please be sure to use github.com/Masterminds/vcs with the capital M.

Quick Usage

Quick usage:

remote := "https://github.com/Masterminds/vcs"
local, _ := ioutil.TempDir("", "go-vcs")
repo, err := NewRepo(remote, local)

In this case NewRepo will detect the VCS is Git and return a GitRepo. All of the repos implement the Repo interface with a common set of features between them.

Supported VCS

Git, SVN, Bazaar (Bzr), and Mercurial (Hg) are currently supported. They each have their own type (e.g., GitRepo) that follow a simple naming pattern. Each type implements the Repo interface and has a constructor (e.g., NewGitRepo). The constructors have the same signature as NewRepo.

Features

  • Clone or checkout a repository depending on the version control system.
  • Pull updates to a repository.
  • Get the currently checked out commit id.
  • Checkout a commit id, branch, or tag (depending on the availability in the VCS).
  • Get a list of tags and branches in the VCS.
  • Check if a string value is a valid reference within the VCS.
  • More...

For more details see the documentation.

Motivation

The package golang.org/x/tools/go/vcs provides some valuable functionality for working with packages in repositories in varying source control management systems. That package, while useful and well tested, is designed with a specific purpose in mind. Our uses went beyond the scope of that package. To implement our scope we built a package that went beyond the functionality and scope of golang.org/x/tools/go/vcs.

# Functions

DetectVcsFromFS detects the type from the local path.
EscapePathSeparator escapes the path separator by replacing it with several.
NewBzrRepo creates a new instance of BzrRepo.
NewGitRepo creates a new instance of GitRepo.
NewHgRepo creates a new instance of HgRepo.
NewLocalError constructs a LocalError.
NewRemoteError constructs a RemoteError.
NewRepo returns a Repo based on trying to detect the source control from the remote and local locations.
NewSvnRepo creates a new instance of SvnRepo.

# Constants

VCS types.
VCS types.
VCS types.
VCS types.
VCS types.

# Variables

ErrCannotDetectVCS is returned when VCS cannot be detected from URI string.
ErrRevisionUnavailable happens when commit revision information is unavailable.
ErrWrongRemote occurs when the passed in remote does not match the VCS configured endpoint.
ErrWrongVCS is returned when an action is tried on the wrong VCS.
Logger is where you can provide a logger, implementing the log.Logger interface, where verbose output from each VCS will be written.

# Structs

BzrRepo implements the Repo interface for the Bzr source control.
CommitInfo contains metadata about a commit.
GitRepo implements the Repo interface for the Git source control.
HgRepo implements the Repo interface for the Mercurial source control.
LocalError is returned when a local operation has an error.
RemoteError is returned when an operation fails against a remote repo.
SvnRepo implements the Repo interface for the Svn source control.

# Interfaces

Repo provides an interface to work with repositories using different source control systems such as Git, Bzr, Mercurial, and SVN.

# Type aliases

Type describes the type of VCS.