dep

package
v0.0.0-...-28bdf3b Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2015 License: MIT Imports: 10 Imported by: 32

Documentation

Overview

Package dep provides a Dependency struct, a DependencyMap from nicknames (strings) to Dependencies, and functions to read and write a DependencyMap to a deps.json file

Index

Constants

View Source
const (
	TypeGit      = "git"
	TypeHg       = "hg"
	TypeBzr      = "bzr"
	TypeGitClone = "git-clone"
)

Dependency Types

View Source
const DepsFile string = "deps.json"

DepsFile is the name of the dependency file

Variables

View Source
var (
	// ErrUnknownType indicates that an unknown dependency type was found
	ErrUnknownType = errors.New("unknown dependency type")

	// ErrMissingAlias indicates that a git-clone dependency requires an alias field
	ErrMissingAlias = errors.New("dependency type git-clone requires alias field")
)

Functions

func GetPath

func GetPath(p string) (result string)

GetPath processes p and returns a clean path ending in deps.json

Types

type Bzr

type Bzr struct{}

Bzr implements the VersionControl interface by using Bazaar

func (*Bzr) Checkout

func (b *Bzr) Checkout(d *Dependency) (err error)

Checkout updates a bzr repo

func (*Bzr) Clean

func (b *Bzr) Clean(d *Dependency)

Clean is a no-op for now

func (*Bzr) Clone

func (b *Bzr) Clone(d *Dependency) (err error)

Clone clones a bzr repo

func (*Bzr) Fetch

func (b *Bzr) Fetch(d *Dependency) (err error)

Fetch pulls in a bzr repo

func (*Bzr) GetHead

func (b *Bzr) GetHead(d *Dependency) (hash string, err error)

GetHead - Render a revspec to a commit ID

func (*Bzr) LastCommit

func (b *Bzr) LastCommit(d *Dependency, branch string) (hash string, err error)

LastCommit retrieves the version number of the last commit on branch Assumes that the current working directory is in the bzr repo

func (*Bzr) Update

func (b *Bzr) Update(d *Dependency) (err error)

Update is a no-op for now

type Dependency

type Dependency struct {
	Repo      string         `json:"repo"`
	Version   string         `json:"version"`
	Type      string         `json:"type"`
	Alias     string         `json:"alias,omitempty"`
	SkipCache bool           `json:"skip-cache,omitempty"`
	VCS       VersionControl `json:"-"`
}

Dependency defines a single dependency

func (*Dependency) Path

func (d *Dependency) Path() (p string)

Path returns the path for this dependency searches for the appropriate directory in each part of the GOPATH (delimited by ':') if not found return the path using the first port of GOPATH

func (*Dependency) SetupVCS

func (d *Dependency) SetupVCS(name string) (err error)

SetupVCS configures the VCS depending on the type

type DependencyMap

type DependencyMap struct {
	Map  map[string]*Dependency
	Path string
}

DependencyMap defines a set of dependencies

func New

func New() (d DependencyMap)

New returns a newly constructed DependencyMap

func Read

func Read(filename string) (deps DependencyMap, err error)

Read reads filename and parses the content into a DependencyMap

func (*DependencyMap) Write

func (d *DependencyMap) Write() (err error)

Write the dependencyMap back into to the file it was read from

type Git

type Git struct{}

Git implements the VersionControl interface by using Git

func (*Git) Checkout

func (g *Git) Checkout(d *Dependency) (err error)

Checkout uses the appropriate VCS to checkout the specified version of the code

func (*Git) Clean

func (g *Git) Clean(d *Dependency)

Clean cleans a git repo: `git reset --hard HEAD ; git clean -fd`

func (*Git) Clone

func (g *Git) Clone(d *Dependency) (err error)

Clone clones d.Repo into d.Path() if d.Path does not exist, otherwise it will cd to d.Path() and run git fetch

func (*Git) Fetch

func (g *Git) Fetch(d *Dependency) (err error)

Fetch fetches a git repo

func (*Git) GetHead

func (g *Git) GetHead(d *Dependency) (hash string, err error)

GetHead - Render a revspec to a commit ID

func (*Git) LastCommit

func (g *Git) LastCommit(d *Dependency, branch string) (hash string, err error)

LastCommit retrieves the version number of the last commit on branch Assumes that the current working directory is in the git repo

func (*Git) Update

func (g *Git) Update(d *Dependency) (err error)

Update updates a git repo

type Hg

type Hg struct{}

Hg implements the VersionControl interface by using Mercurial

func (*Hg) Checkout

func (h *Hg) Checkout(d *Dependency) (err error)

Checkout updates a mercurial repo

func (*Hg) Clean

func (h *Hg) Clean(d *Dependency)

Clean cleans a mercurial repo

func (*Hg) Clone

func (h *Hg) Clone(d *Dependency) (err error)

Clone uses go get to clone a mercurial repo

func (*Hg) Fetch

func (h *Hg) Fetch(d *Dependency) (err error)

Fetch fetches a mercurial repo

func (*Hg) GetHead

func (h *Hg) GetHead(d *Dependency) (hash string, err error)

GetHead - Render a revspec to a commit ID

func (*Hg) LastCommit

func (h *Hg) LastCommit(d *Dependency, branch string) (hash string, err error)

LastCommit retrieves the version number of the last commit on branch Assumes that the current working directory is in the hg repo

func (*Hg) Update

func (h *Hg) Update(d *Dependency) (err error)

Update updates a mercurial repo

type VersionControl

type VersionControl interface {
	Clone(d *Dependency) (err error)

	// Get changes from the server
	Fetch(d *Dependency) (err error)

	// Pull/Merge/Update this branch
	Update(d *Dependency) (err error)

	Checkout(d *Dependency) (err error)

	LastCommit(d *Dependency, branch string) (hash string, err error)
	GetHead(d *Dependency) (to_return string, err error)

	Clean(d *Dependency)
}

VersionControl is an interface that define a standard set of operations that can be completed by a version control system

Jump to

Keyboard shortcuts

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