aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-04-18 16:37:30 +0200
committerGitHub <noreply@github.com>2018-04-18 16:37:30 +0200
commit87cc8192de93dcf7b843058f11ad85200d46bb0c (patch)
treedafcbe0c3c76881e7066c8505a8cdbf92be9f8ec /worktree_test.go
parentb30763cb64afa91c016b23e905af0a378eb1b76d (diff)
parent6b33126e79695b499d7d519f69db4ca1ebd22dd1 (diff)
downloadgo-git-87cc8192de93dcf7b843058f11ad85200d46bb0c.tar.gz
Merge pull request #815 from kuba--/fix-worktree/814
Fix for "Worktree Add function adds ".git" directory"
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go
index b3e0a1a..05a205a 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -3,12 +3,14 @@ package git
import (
"bytes"
"context"
+ "errors"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"runtime"
"testing"
+ "time"
"gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -1833,3 +1835,39 @@ func (s *WorktreeSuite) TestGrep(c *C) {
}
}
}
+
+func (s *WorktreeSuite) TestAddAndCommit(c *C) {
+ dir, err := ioutil.TempDir("", "plain-repo")
+ c.Assert(err, IsNil)
+ defer os.RemoveAll(dir)
+
+ repo, err := PlainInit(dir, false)
+ c.Assert(err, IsNil)
+
+ w, err := repo.Worktree()
+ c.Assert(err, IsNil)
+
+ _, err = w.Add(".")
+ c.Assert(err, IsNil)
+
+ w.Commit("Test Add And Commit", &CommitOptions{Author: &object.Signature{
+ Name: "foo",
+ Email: "foo@foo.foo",
+ When: time.Now(),
+ }})
+
+ iter, err := w.r.Log(&LogOptions{})
+ c.Assert(err, IsNil)
+ err = iter.ForEach(func(c *object.Commit) error {
+ files, err := c.Files()
+ if err != nil {
+ return err
+ }
+
+ err = files.ForEach(func(f *object.File) error {
+ return errors.New("Expected no files, got at least 1")
+ })
+ return err
+ })
+ c.Assert(err, IsNil)
+}