Skip to content

Commit 7852603

Browse files
committed
Added initial documentation for end users.
1 parent ade5f73 commit 7852603

File tree

3 files changed

+57
-5
lines changed

3 files changed

+57
-5
lines changed

LICENSE.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
The Masterminds
22
Copyright (C) 2014-2015, Matt Butcher and Matt Farina
3-
Copyright (C) 2015, Google
43

54
Permission is hereby granted, free of charge, to any person obtaining a copy
65
of this software and associated documentation files (the "Software"), to deal

README.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1-
# go-vcs
1+
# VCS Repository Management for Go
22

3+
Manage repos in varying version control systems with ease through a common
4+
interface.
5+
6+
## Quick Usage
7+
8+
Quick usage:
9+
10+
remote := "https://github.com/Masterminds/go-vcs"
11+
local, _ := ioutil.TempDir("", "go-vcs")
12+
repo, err := NewRepo(remote, local)
13+
14+
In this case `NewRepo` will detect the VCS is Git and return a `GitRepo`. All of
15+
the repos implement the `Repo` interface with a common set of features between
16+
them.
17+
18+
## Supported VCS
19+
20+
Git, SVN, Bazaar (Bzr), and Mercurial (Hg) are currently supported. They each
21+
have their own type (e.g., `GitRepo`) that follow a simple naming pattern. Each
22+
type implements the `Repo` interface and has a constructor (e.g., `NewGitRepo`).
23+
The constructors have the same signature as `NewRepo`.
24+
25+
## Motivation
26+
27+
The package `golang.org/x/tools/go/vcs` provides some valuable functionality
28+
for working with packages in repositories in varying source control management
29+
systems. That package, while useful and well tested, is designed with a specific
30+
purpose in mind. Our uses went beyond the scope of that package. To implement
31+
our scope we built a package that went beyond the functionality and scope
32+
of `golang.org/x/tools/go/vcs`.

repo.go

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1-
// Package vcs provides the ability to work with varying version control systems (VCS),
2-
// also known as source control systems (SCM) though the same interface.
1+
// Package vcs provides the ability to work with varying version control systems
2+
// (VCS), also known as source control systems (SCM) though the same interface.
3+
//
4+
// This package includes a function that attempts to detect the repo type from
5+
// the remote URL and return the proper type. For example,
6+
//
7+
// remote := "https://github.com/Masterminds/go-vcs"
8+
// local, _ := ioutil.TempDir("", "go-vcs")
9+
// repo, err := NewRepo(remote, local)
10+
//
11+
// In this case repo will be a GitRepo instance. NewRepo can detect the VCS for
12+
// numerous popular VCS and from the URL. For example, a URL ending in .git
13+
// that's not from one of the popular VCS will be detected as a Git repo and
14+
// the correct type will be returned.
15+
//
16+
// If you know the repository type and would like to create an instance of a
17+
// specific type you can use one of constructors for a type. They are NewGitRepo,
18+
// NewSvnRepo, NewBzrRepo, and NewHgRepo. The definition and usage is the same
19+
// as NewRepo.
20+
//
21+
// Once you have an object implementing the Repo interface the operations are
22+
// the same no matter which VCS you're using. There are some caveats. For
23+
// example, each VCS has its own version formats that need to be respected and
24+
// checkout out branches, if a branch is being worked with, is different in
25+
// each VCS.
326
package vcs
427

528
import (
@@ -28,7 +51,7 @@ var (
2851
// of the provided logger.
2952
var Logger *log.Logger = log.New(ioutil.Discard, "go-vcs", log.LstdFlags)
3053

31-
// VcsType descripbes the type of VCS
54+
// VcsType describes the type of VCS
3255
type VcsType string
3356

3457
// VCS types

0 commit comments

Comments
 (0)