vcs

package module
v0.0.0-...-adaa493 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2014 License: MPL-2.0 Imports: 12 Imported by: 0

README

vcs

VCS interfaces for Go (golang) - Supports Git, Mercurial and Bazaar

To install vcs run the following command:

 go get gopkgs.com/vcs.v1

Then use the following import path to ensure a stable API:

  import "gopkgs.com/vcs.v1"

For documentation and available versions, see http://gopkgs.com/vcs.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoVCS is returned when no VCS can be found at the given
	// path.
	ErrNoVCS = errors.New("could not find an VCS at the given path")
)

Functions

func Register

func Register(iface Interface)

Register adds a new Interface to the list of supported VCS interfaces. To allow overriding the defaults, Register adds the new Interface at the start of the internal Interface list.

Types

type Branch

type Branch struct {
	Name     string
	Revision string
}

type Interface

type Interface interface {
	Cmd() string
	Dir() string
	Head() string
	Revision(id string) []string
	History(since string) []string
	Checkout(rev string) []string
	Clone(src string, dst string) []string
	Update() []string
	ParseRevisions(since string, data []byte) ([]*Revision, error)
	Branches() []string
	Tags() []string
	ParseBranches(data []byte) ([]*Branch, error)
	ParseTags(data []byte) ([]*Tag, error)
}

Interface is the interface implemented by VCS systems. To register a new one, use Register.

type Revision

type Revision struct {
	Identifier      string
	ShortIdentifier string
	Subject         string
	Message         string
	Author          string
	Email           string
	Diff            string
	Timestamp       time.Time
}

type Tag

type Tag struct {
	Name     string
	Revision string
}

type Tester

type Tester interface {
	// Test returns true if the absolute directory dir
	// contains a repository.
	Test(dir string) bool
}

Tester is an optional interface which Interfaces might implement to test if a dir contains a repository which they can understand.

type VCS

type VCS struct {
	// Dir is the absolute path of the repository root.
	Dir string
	// contains filtered or unexported fields
}

VCS represents a VCS system on a given directory.

func New

func New(dir string) (*VCS, error)

New starts at the given directory and walks up until it finds an VCS. If no VCS could be found, an error is returned.

func NewAt

func NewAt(dir string) (*VCS, error)

NewAt works like New, but does not walk up into the the parent directories. Id est, it will only succeed if the given directory is the root directory of a VCS checkout.

func (*VCS) Branches

func (v *VCS) Branches() ([]*Branch, error)

Branches returns the available branches in the VCS.

func (*VCS) Checkout

func (v *VCS) Checkout(rev string) error

Checkout discards all local changes in VCS and updates the working copy to the given revision. If no revision is given, the one returned by v.Last() will be checked out.

func (*VCS) CheckoutAt

func (v *VCS) CheckoutAt(rev string, dir string) (*VCS, error)

CheckoutAt works like Checkout, but creates a copy of the repository at the given directory before perforing the Checkout. The returned VCS is the new one created at dir.

func (*VCS) History

func (v *VCS) History(since string) ([]*Revision, error)

History returns all the revisions from the VCS which are newer than the revision identified by the since parameter, which might be either a short or a long revision identifier. If since is empty, all the history is returned.

func (*VCS) Last

func (v *VCS) Last() (*Revision, error)

Last returns the last revision from the default branch, known as HEAD in git or tip in mercurial.

func (*VCS) Name

func (v *VCS) Name() string

Name returns the name of the underlyng VCS interface (e.g. git, mercurial, ...).

func (*VCS) Revision

func (v *VCS) Revision(id string) (*Revision, error)

Revision returns the revision identified by the given id, which might be either a short or a long revision identifier.

func (*VCS) Tags

func (v *VCS) Tags() ([]*Tag, error)

Branches returns the available tags in the VCS.

func (*VCS) Update

func (v *VCS) Update() error

Update updates the VCS from its upstream. If there's no upstream, an error will be returned.

Jump to

Keyboard shortcuts

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