Merge pull request #406 from Masterminds/feat/vcs-1.7
Updated to Masterminds/vcs 1.7.0
diff --git a/glide.lock b/glide.lock
index 7557f3e..8bb73d6 100644
--- a/glide.lock
+++ b/glide.lock
@@ -1,12 +1,12 @@
-hash: 78e2fef6acf410a5c01231739017e3b0fe7762e815bf1a9b1e577ed5af1d5693
-updated: 2016-04-27T11:53:07.688047146-04:00
+hash: ebc39e5b2036ba2235316f2897fb9f2e696c6a7d5389416812722cc8ed3dfa21
+updated: 2016-05-05T09:44:44.751721442-04:00
imports:
- name: github.com/codegangsta/cli
version: 71f57d300dd6a780ac1856c005c4b518cfd498ec
- name: github.com/Masterminds/semver
version: 808ed7761c233af2de3f9729a041d68c62527f3a
- name: github.com/Masterminds/vcs
- version: f6cc1e9e7389eea70d925c03eea2d6f8670f5109
+ version: 7af28b64c5ec41b1558f5514fd938379822c237c
- name: gopkg.in/yaml.v2
version: a83829b6f1293c91addabc89d0571c246397bbf4
devImports: []
diff --git a/glide.yaml b/glide.yaml
index 1018832..a8c5b4a 100644
--- a/glide.yaml
+++ b/glide.yaml
@@ -11,8 +11,8 @@
import:
- package: gopkg.in/yaml.v2
- package: github.com/Masterminds/vcs
- version: ^1.6.1
+ version: ^1.7.0
- package: github.com/codegangsta/cli
- version: ^1.14.0
+ version: ~1.14.0
- package: github.com/Masterminds/semver
version: ^1.0.0
diff --git a/vendor/github.com/Masterminds/vcs/.travis.yml b/vendor/github.com/Masterminds/vcs/.travis.yml
index db6044d..a8c32da 100644
--- a/vendor/github.com/Masterminds/vcs/.travis.yml
+++ b/vendor/github.com/Masterminds/vcs/.travis.yml
@@ -7,6 +7,10 @@
- 1.6
- tip
+before_script:
+ - git version
+ - svn --version
+
# Setting sudo access to false will let Travis CI use containers rather than
# VMs to run the tests. For more details see:
# - http://docs.travis-ci.com/user/workers/container-based-infrastructure/
diff --git a/vendor/github.com/Masterminds/vcs/CHANGELOG.md b/vendor/github.com/Masterminds/vcs/CHANGELOG.md
index a33839a..d178685 100644
--- a/vendor/github.com/Masterminds/vcs/CHANGELOG.md
+++ b/vendor/github.com/Masterminds/vcs/CHANGELOG.md
@@ -1,3 +1,12 @@
+1.7.0 (2016-05-05)
+
+- Adds a glide.yaml file with some limited information.
+- Implements #37: Ability to export source as a directory.
+- Implements #36: Get current version-ish with Current method. This returns
+ a branch (if on tip) or equivalent tip, a tag if on a tag, or a revision if
+ on an individual revision. Note, the tip of branch is VCS specific so usage
+ may require detecting VCS type.
+
# 1.6.1 (2016-04-27)
- Fixed #30: tags from commit should not have ^{} appended (seen in git)
diff --git a/vendor/github.com/Masterminds/vcs/bzr.go b/vendor/github.com/Masterminds/vcs/bzr.go
index 1d36137..a62451f 100644
--- a/vendor/github.com/Masterminds/vcs/bzr.go
+++ b/vendor/github.com/Masterminds/vcs/bzr.go
@@ -147,6 +147,36 @@
return strings.TrimSpace(string(out)), nil
}
+// Current returns the current version-ish. This means:
+// * -1 if on the tip of the branch (this is the Bzr value for HEAD)
+// * A tag if on a tag
+// * Otherwise a revision
+func (s *BzrRepo) Current() (string, error) {
+ tip, err := s.CommitInfo("-1")
+ if err != nil {
+ return "", err
+ }
+
+ curr, err := s.Version()
+ if err != nil {
+ return "", err
+ }
+
+ if tip.Commit == curr {
+ return "-1", nil
+ }
+
+ ts, err := s.TagsFromCommit(curr)
+ if err != nil {
+ return "", err
+ }
+ if len(ts) > 0 {
+ return ts[0], nil
+ }
+
+ return curr, nil
+}
+
// Date retrieves the date on the latest commit.
func (s *BzrRepo) Date() (time.Time, error) {
out, err := s.RunFromDir("bzr", "version-info", "--custom", "--template={date}")
@@ -214,9 +244,7 @@
return nil, ErrRevisionUnavailable
}
- ci := &CommitInfo{
- Commit: id,
- }
+ ci := &CommitInfo{}
lines := strings.Split(string(out), "\n")
const format = "Mon 2006-01-02 15:04:05 -0700"
var track int
@@ -224,7 +252,9 @@
// Note, bzr does not appear to use i18m.
for i, l := range lines {
- if strings.HasPrefix(l, "committer:") {
+ if strings.HasPrefix(l, "revno:") {
+ ci.Commit = strings.TrimSpace(strings.TrimPrefix(l, "revno:"))
+ } else if strings.HasPrefix(l, "committer:") {
ci.Author = strings.TrimSpace(strings.TrimPrefix(l, "committer:"))
} else if strings.HasPrefix(l, "timestamp:") {
ts := strings.TrimSpace(strings.TrimPrefix(l, "timestamp:"))
@@ -291,6 +321,17 @@
return true
}
+// ExportDir exports the current revision to the passed in directory.
+func (s *BzrRepo) ExportDir(dir string) error {
+ out, err := s.RunFromDir("bzr", "export", dir)
+ s.log(out)
+ if err != nil {
+ return NewLocalError("Unable to export source", err, string(out))
+ }
+
+ return nil
+}
+
// Multi-lingual manner check for the VCS error that it couldn't create directory.
// https://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/files/head:/po/
func (s *BzrRepo) isUnableToCreateDir(err error) bool {
diff --git a/vendor/github.com/Masterminds/vcs/bzr_test.go b/vendor/github.com/Masterminds/vcs/bzr_test.go
index 6125444..e12c6d3 100644
--- a/vendor/github.com/Masterminds/vcs/bzr_test.go
+++ b/vendor/github.com/Masterminds/vcs/bzr_test.go
@@ -2,6 +2,7 @@
import (
"io/ioutil"
+ "path/filepath"
"time"
//"log"
"os"
@@ -78,13 +79,21 @@
t.Error("Wrong version returned from NewRepo")
}
+ v, err := repo.Current()
+ if err != nil {
+ t.Errorf("Error trying Bzr Current: %s", err)
+ }
+ if v != "-1" {
+ t.Errorf("Current failed to detect Bzr on tip of branch. Got version: %s", v)
+ }
+
err = repo.UpdateVersion("2")
if err != nil {
t.Errorf("Unable to update Bzr repo version. Err was %s", err)
}
// Use Version to verify we are on the right version.
- v, err := repo.Version()
+ v, err = repo.Version()
if v != "2" {
t.Error("Error checking checked out Bzr version")
}
@@ -92,6 +101,14 @@
t.Error(err)
}
+ v, err = repo.Current()
+ if err != nil {
+ t.Errorf("Error trying Bzr Current: %s", err)
+ }
+ if v != "2" {
+ t.Errorf("Current failed to detect Bzr on rev 2 of branch. Got version: %s", v)
+ }
+
// Use Date to verify we are on the right commit.
d, err := repo.Date()
if d.Format(longForm) != "2015-07-31 09:50:42 -0400" {
@@ -184,6 +201,38 @@
if err != ErrRevisionUnavailable {
t.Error("Bzr didn't return expected ErrRevisionUnavailable")
}
+
+ tempDir2, err := ioutil.TempDir("", "go-vcs-bzr-tests-export")
+ if err != nil {
+ t.Fatalf("Error creating temp directory: %s", err)
+ }
+ defer func() {
+ err = os.RemoveAll(tempDir2)
+ if err != nil {
+ t.Error(err)
+ }
+ }()
+
+ exportDir := filepath.Join(tempDir2, "src")
+
+ err = repo.ExportDir(exportDir)
+ if err != nil {
+ t.Errorf("Unable to export Bzr repo. Err was %s", err)
+ }
+
+ _, err = os.Stat(filepath.Join(exportDir, "Readme.md"))
+ if err != nil {
+ t.Errorf("Error checking exported file in Bzr: %s", err)
+ }
+
+ _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs())))
+ if err != nil {
+ if found := os.IsNotExist(err); found == false {
+ t.Errorf("Error checking exported metadata in Bzr: %s", err)
+ }
+ } else {
+ t.Error("Error checking Bzr metadata. It exists.")
+ }
}
func TestBzrCheckLocal(t *testing.T) {
diff --git a/vendor/github.com/Masterminds/vcs/git.go b/vendor/github.com/Masterminds/vcs/git.go
index 26d50ee..778b6af 100644
--- a/vendor/github.com/Masterminds/vcs/git.go
+++ b/vendor/github.com/Masterminds/vcs/git.go
@@ -169,6 +169,34 @@
return strings.TrimSpace(string(out)), nil
}
+// Current returns the current version-ish. This means:
+// * Branch name if on the tip of the branch
+// * Tag if on a tag
+// * Otherwise a revision id
+func (s *GitRepo) Current() (string, error) {
+ out, err := s.RunFromDir("git", "symbolic-ref", "HEAD")
+ if err == nil {
+ o := bytes.TrimSpace(bytes.TrimPrefix(out, []byte("refs/heads/")))
+ return string(o), nil
+ }
+
+ v, err := s.Version()
+ if err != nil {
+ return "", err
+ }
+
+ ts, err := s.TagsFromCommit(v)
+ if err != nil {
+ return "", err
+ }
+
+ if len(ts) > 0 {
+ return ts[0], nil
+ }
+
+ return v, nil
+}
+
// Date retrieves the date on the latest commit.
func (s *GitRepo) Date() (time.Time, error) {
out, err := s.RunFromDir("git", "log", "-1", "--date=iso", "--pretty=format:%cd")
@@ -314,6 +342,23 @@
return true
}
+// ExportDir exports the current revision to the passed in directory.
+func (s *GitRepo) ExportDir(dir string) error {
+
+ // Without the trailing / there can be problems.
+ if !strings.HasSuffix(dir, string(os.PathSeparator)) {
+ dir = dir + string(os.PathSeparator)
+ }
+
+ out, err := s.RunFromDir("git", "checkout-index", "-f", "-a", "--prefix="+dir)
+ s.log(out)
+ if err != nil {
+ return NewLocalError("Unable to export source", err, string(out))
+ }
+
+ return nil
+}
+
// isDetachedHead will detect if git repo is in "detached head" state.
func isDetachedHead(dir string) (bool, error) {
p := filepath.Join(dir, ".git", "HEAD")
diff --git a/vendor/github.com/Masterminds/vcs/git_test.go b/vendor/github.com/Masterminds/vcs/git_test.go
index 5fe6259..80eae55 100644
--- a/vendor/github.com/Masterminds/vcs/git_test.go
+++ b/vendor/github.com/Masterminds/vcs/git_test.go
@@ -2,6 +2,7 @@
import (
"io/ioutil"
+ "path/filepath"
"time"
//"log"
"os"
@@ -82,6 +83,14 @@
t.Error(err)
}
+ v, err := repo.Current()
+ if err != nil {
+ t.Errorf("Error trying Git Current: %s", err)
+ }
+ if v != "master" {
+ t.Errorf("Current failed to detect Git on tip of master. Got version: %s", v)
+ }
+
// Set the version using the short hash.
err = repo.UpdateVersion("806b07b")
if err != nil {
@@ -98,7 +107,7 @@
}
// Use Version to verify we are on the right version.
- v, err := repo.Version()
+ v, err = repo.Version()
if v != "806b07b08faa21cfbdae93027904f80174679402" {
t.Error("Error checking checked out Git version")
}
@@ -106,6 +115,14 @@
t.Error(err)
}
+ v, err = repo.Current()
+ if err != nil {
+ t.Errorf("Error trying Git Current for ref: %s", err)
+ }
+ if v != "806b07b08faa21cfbdae93027904f80174679402" {
+ t.Errorf("Current failed to detect Git on ref of branch. Got version: %s", v)
+ }
+
// Use Date to verify we are on the right commit.
d, err := repo.Date()
if d.Format(longForm) != "2015-07-29 09:46:39 -0400" {
@@ -202,6 +219,38 @@
if err != ErrRevisionUnavailable {
t.Error("Git didn't return expected ErrRevisionUnavailable")
}
+
+ tempDir2, err := ioutil.TempDir("", "go-vcs-git-tests-export")
+ if err != nil {
+ t.Fatalf("Error creating temp directory: %s", err)
+ }
+ defer func() {
+ err = os.RemoveAll(tempDir2)
+ if err != nil {
+ t.Error(err)
+ }
+ }()
+
+ exportDir := filepath.Join(tempDir2, "src")
+
+ err = repo.ExportDir(exportDir)
+ if err != nil {
+ t.Errorf("Unable to export Git repo. Err was %s", err)
+ }
+
+ _, err = os.Stat(filepath.Join(exportDir, "README.md"))
+ if err != nil {
+ t.Errorf("Error checking exported file in Git: %s", err)
+ }
+
+ _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs())))
+ if err != nil {
+ if found := os.IsNotExist(err); found == false {
+ t.Errorf("Error checking exported metadata in Git: %s", err)
+ }
+ } else {
+ t.Error("Error checking Git metadata. It exists.")
+ }
}
func TestGitCheckLocal(t *testing.T) {
diff --git a/vendor/github.com/Masterminds/vcs/glide.yaml b/vendor/github.com/Masterminds/vcs/glide.yaml
new file mode 100644
index 0000000..b96e0bd
--- /dev/null
+++ b/vendor/github.com/Masterminds/vcs/glide.yaml
@@ -0,0 +1,8 @@
+package: github.com/Masterminds/vcs
+homepage: https://github.com/Masterminds/vcs
+license: MIT
+owners:
+- name: Matt Farina
+ email: matt@mattfarina.com
+ homepage: https://www.mattfarina.com/
+import: []
diff --git a/vendor/github.com/Masterminds/vcs/hg.go b/vendor/github.com/Masterminds/vcs/hg.go
index 4ce055c..0d7a994 100644
--- a/vendor/github.com/Masterminds/vcs/hg.go
+++ b/vendor/github.com/Masterminds/vcs/hg.go
@@ -106,7 +106,7 @@
// Version retrieves the current version.
func (s *HgRepo) Version() (string, error) {
- out, err := s.RunFromDir("hg", "identify")
+ out, err := s.RunFromDir("hg", "--debug", "identify")
if err != nil {
return "", NewLocalError("Unable to retrieve checked out version", err, string(out))
}
@@ -116,6 +116,43 @@
return strings.TrimSpace(sha), nil
}
+// Current returns the current version-ish. This means:
+// * Branch name if on the tip of the branch
+// * Tag if on a tag
+// * Otherwise a revision id
+func (s *HgRepo) Current() (string, error) {
+ out, err := s.RunFromDir("hg", "branch")
+ if err != nil {
+ return "", err
+ }
+ branch := strings.TrimSpace(string(out))
+
+ tip, err := s.CommitInfo("max(branch(" + branch + "))")
+ if err != nil {
+ return "", err
+ }
+
+ curr, err := s.Version()
+ if err != nil {
+ return "", err
+ }
+
+ if tip.Commit == curr {
+
+ return branch, nil
+ }
+
+ ts, err := s.TagsFromCommit(curr)
+ if err != nil {
+ return "", err
+ }
+ if len(ts) > 0 {
+ return ts[0], nil
+ }
+
+ return curr, nil
+}
+
// Date retrieves the date on the latest commit.
func (s *HgRepo) Date() (time.Time, error) {
version, err := s.Version()
@@ -270,3 +307,15 @@
return true
}
+
+// ExportDir exports the current revision to the passed in directory.
+func (s *HgRepo) ExportDir(dir string) error {
+
+ out, err := s.RunFromDir("hg", "archive", dir)
+ s.log(out)
+ if err != nil {
+ return NewLocalError("Unable to export source", err, string(out))
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/Masterminds/vcs/hg_test.go b/vendor/github.com/Masterminds/vcs/hg_test.go
index d63f0d8..b8aa39a 100644
--- a/vendor/github.com/Masterminds/vcs/hg_test.go
+++ b/vendor/github.com/Masterminds/vcs/hg_test.go
@@ -2,6 +2,7 @@
import (
"io/ioutil"
+ "path/filepath"
"strings"
"time"
//"log"
@@ -78,6 +79,14 @@
t.Error("Wrong version returned from NewRepo")
}
+ v, err := repo.Current()
+ if err != nil {
+ t.Errorf("Error trying Hg Current: %s", err)
+ }
+ if v != "default" {
+ t.Errorf("Current failed to detect Hg on tip of default. Got version: %s", v)
+ }
+
// Set the version using the short hash.
err = repo.UpdateVersion("a5494ba2177f")
if err != nil {
@@ -85,14 +94,22 @@
}
// Use Version to verify we are on the right version.
- v, err := repo.Version()
- if v != "a5494ba2177f" {
- t.Error("Error checking checked out Hg version")
+ v, err = repo.Version()
+ if v != "a5494ba2177ff9ef26feb3c155dfecc350b1a8ef" {
+ t.Errorf("Error checking checked out Hg version: %s", v)
}
if err != nil {
t.Error(err)
}
+ v, err = repo.Current()
+ if err != nil {
+ t.Errorf("Error trying Hg Current for ref: %s", err)
+ }
+ if v != "a5494ba2177ff9ef26feb3c155dfecc350b1a8ef" {
+ t.Errorf("Current failed to detect Hg on ref of branch. Got version: %s", v)
+ }
+
// Use Date to verify we are on the right commit.
d, err := repo.Date()
if err != nil {
@@ -109,8 +126,8 @@
}
v, err = repo.Version()
- if v != "9c6ccbca73e8" {
- t.Error("Error checking checked out Hg version")
+ if v != "9c6ccbca73e8a1351c834f33f57f1f7a0329ad35" {
+ t.Errorf("Error checking checked out Hg version: %s", v)
}
if err != nil {
t.Error(err)
@@ -188,6 +205,38 @@
if err != ErrRevisionUnavailable {
t.Error("Hg didn't return expected ErrRevisionUnavailable")
}
+
+ tempDir2, err := ioutil.TempDir("", "go-vcs-hg-tests-export")
+ if err != nil {
+ t.Fatalf("Error creating temp directory: %s", err)
+ }
+ defer func() {
+ err = os.RemoveAll(tempDir2)
+ if err != nil {
+ t.Error(err)
+ }
+ }()
+
+ exportDir := filepath.Join(tempDir2, "src")
+
+ err = repo.ExportDir(exportDir)
+ if err != nil {
+ t.Errorf("Unable to export Hg repo. Err was %s", err)
+ }
+
+ _, err = os.Stat(filepath.Join(exportDir, "Readme.md"))
+ if err != nil {
+ t.Errorf("Error checking exported file in Hg: %s", err)
+ }
+
+ _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs())))
+ if err != nil {
+ if found := os.IsNotExist(err); found == false {
+ t.Errorf("Error checking exported metadata in Hg: %s", err)
+ }
+ } else {
+ t.Error("Error checking Hg metadata. It exists.")
+ }
}
func TestHgCheckLocal(t *testing.T) {
diff --git a/vendor/github.com/Masterminds/vcs/repo.go b/vendor/github.com/Masterminds/vcs/repo.go
index 61a39a0..99bc2d2 100644
--- a/vendor/github.com/Masterminds/vcs/repo.go
+++ b/vendor/github.com/Masterminds/vcs/repo.go
@@ -92,6 +92,12 @@
// Version retrieves the current version.
Version() (string, error)
+ // Current retrieves the current version-ish. This is different from the
+ // Version method. The output could be a branch name if on the tip of a
+ // branch (git), a tag if on a tag, a revision if on a specific revision
+ // that's not the tip of the branch. The values here vary based on the VCS.
+ Current() (string, error)
+
// Date retrieves the date on the latest commit.
Date() (time.Time, error)
@@ -123,6 +129,9 @@
// RunFromDir executes a command from repo's directory.
RunFromDir(cmd string, args ...string) ([]byte, error)
+
+ // ExportDir exports the current revision to the passed in directory.
+ ExportDir(string) error
}
// NewRepo returns a Repo based on trying to detect the source control from the
diff --git a/vendor/github.com/Masterminds/vcs/svn.go b/vendor/github.com/Masterminds/vcs/svn.go
index 85f60b5..48d089b 100644
--- a/vendor/github.com/Masterminds/vcs/svn.go
+++ b/vendor/github.com/Masterminds/vcs/svn.go
@@ -126,12 +126,43 @@
// Version retrieves the current version.
func (s *SvnRepo) Version() (string, error) {
- out, err := s.RunFromDir("svnversion", ".")
+ type Commit struct {
+ Revision string `xml:"revision,attr"`
+ }
+ type Info struct {
+ Commit Commit `xml:"entry>commit"`
+ }
+
+ out, err := s.RunFromDir("svn", "info", "--xml")
s.log(out)
+ infos := &Info{}
+ err = xml.Unmarshal(out, &infos)
if err != nil {
return "", NewLocalError("Unable to retrieve checked out version", err, string(out))
}
- return strings.TrimSpace(string(out)), nil
+
+ return infos.Commit.Revision, nil
+}
+
+// Current returns the current version-ish. This means:
+// * HEAD if on the tip.
+// * Otherwise a revision id
+func (s *SvnRepo) Current() (string, error) {
+ tip, err := s.CommitInfo("HEAD")
+ if err != nil {
+ return "", err
+ }
+
+ curr, err := s.Version()
+ if err != nil {
+ return "", err
+ }
+
+ if tip.Commit == curr {
+ return "HEAD", nil
+ }
+
+ return curr, nil
}
// Date retrieves the date on the latest commit.
@@ -209,6 +240,31 @@
// CommitInfo retrieves metadata about a commit.
func (s *SvnRepo) CommitInfo(id string) (*CommitInfo, error) {
+
+ // There are cases where Svn log doesn't return anything for HEAD or BASE.
+ // svn info does provide details for these but does not have elements like
+ // the commit message.
+ if id == "HEAD" || id == "BASE" {
+ type Commit struct {
+ Revision string `xml:"revision,attr"`
+ }
+ type Info struct {
+ Commit Commit `xml:"entry>commit"`
+ }
+
+ out, err := s.RunFromDir("svn", "info", "-r", id, "--xml")
+ infos := &Info{}
+ err = xml.Unmarshal(out, &infos)
+ if err != nil {
+ return nil, NewLocalError("Unable to retrieve commit information", err, string(out))
+ }
+
+ id = infos.Commit.Revision
+ if id == "" {
+ return nil, ErrRevisionUnavailable
+ }
+ }
+
out, err := s.RunFromDir("svn", "log", "-r", id, "--xml")
if err != nil {
return nil, NewRemoteError("Unable to retrieve commit information", err, string(out))
@@ -266,6 +322,18 @@
return true
}
+// ExportDir exports the current revision to the passed in directory.
+func (s *SvnRepo) ExportDir(dir string) error {
+
+ out, err := s.RunFromDir("svn", "export", ".", dir)
+ s.log(out)
+ if err != nil {
+ return NewLocalError("Unable to export source", err, string(out))
+ }
+
+ return nil
+}
+
// isUnableToCreateDir checks for an error in Init() to see if an error
// where the parent directory of the VCS local path doesn't exist.
func (s *SvnRepo) isUnableToCreateDir(err error) bool {
diff --git a/vendor/github.com/Masterminds/vcs/svn_test.go b/vendor/github.com/Masterminds/vcs/svn_test.go
index 349b072..d242f3e 100644
--- a/vendor/github.com/Masterminds/vcs/svn_test.go
+++ b/vendor/github.com/Masterminds/vcs/svn_test.go
@@ -2,6 +2,7 @@
import (
"io/ioutil"
+ "path/filepath"
"time"
//"log"
"os"
@@ -87,6 +88,14 @@
// t.Error("Wrong version returned from NewRepo")
// }
+ v, err := repo.Current()
+ if err != nil {
+ t.Errorf("Error trying Svn Current: %s", err)
+ }
+ if v != "HEAD" {
+ t.Errorf("Current failed to detect Svn on HEAD. Got version: %s", v)
+ }
+
// Update the version to a previous version.
err = repo.UpdateVersion("r2")
if err != nil {
@@ -94,7 +103,7 @@
}
// Use Version to verify we are on the right version.
- v, err := repo.Version()
+ v, err = repo.Version()
if v != "2" {
t.Error("Error checking checked SVN out version")
}
@@ -102,6 +111,14 @@
t.Error(err)
}
+ v, err = repo.Current()
+ if err != nil {
+ t.Errorf("Error trying Svn Current for ref: %s", err)
+ }
+ if v != "2" {
+ t.Errorf("Current failed to detect Svn on HEAD. Got version: %s", v)
+ }
+
// Perform an update which should take up back to the latest version.
err = repo.Update()
if err != nil {
@@ -187,6 +204,38 @@
if err != ErrRevisionUnavailable {
t.Error("Svn didn't return expected ErrRevisionUnavailable")
}
+
+ tempDir2, err := ioutil.TempDir("", "go-vcs-svn-tests-export")
+ if err != nil {
+ t.Fatalf("Error creating temp directory: %s", err)
+ }
+ defer func() {
+ err = os.RemoveAll(tempDir2)
+ if err != nil {
+ t.Error(err)
+ }
+ }()
+
+ exportDir := filepath.Join(tempDir2, "src")
+
+ err = repo.ExportDir(exportDir)
+ if err != nil {
+ t.Errorf("Unable to export Svn repo. Err was %s", err)
+ }
+
+ _, err = os.Stat(filepath.Join(exportDir, "README.md"))
+ if err != nil {
+ t.Errorf("Error checking exported file in Svn: %s", err)
+ }
+
+ _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs())))
+ if err != nil {
+ if found := os.IsNotExist(err); found == false {
+ t.Errorf("Error checking exported metadata in Svn: %s", err)
+ }
+ } else {
+ t.Error("Error checking Svn metadata. It exists.")
+ }
}
func TestSvnCheckLocal(t *testing.T) {