Socket
Socket
Sign inDemoInstall

github.com/Masterminds/vcs

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/Masterminds/vcs

Package vcs provides the ability to work with varying version control systems (VCS), also known as source control systems (SCM) though the same interface. This package includes a function that attempts to detect the repo type from the remote URL and return the proper type. For example, In this case repo will be a GitRepo instance. NewRepo can detect the VCS for numerous popular VCS and from the URL. For example, a URL ending in .git that's not from one of the popular VCS will be detected as a Git repo and the correct type will be returned. If you know the repository type and would like to create an instance of a specific type you can use one of constructors for a type. They are NewGitRepo, NewSvnRepo, NewBzrRepo, and NewHgRepo. The definition and usage is the same as NewRepo. Once you have an object implementing the Repo interface the operations are the same no matter which VCS you're using. There are some caveats. For example, each VCS has its own version formats that need to be respected and checkout out branches, if a branch is being worked with, is different in each VCS.


Version published

Readme

Source

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.

FAQs

Last updated on 31 Mar 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc