aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorkuba-- <kuba@sourced.tech>2018-04-18 10:35:07 +0200
committerkuba-- <kuba@sourced.tech>2018-04-18 15:25:28 +0200
commit6b33126e79695b499d7d519f69db4ca1ebd22dd1 (patch)
treedafcbe0c3c76881e7066c8505a8cdbf92be9f8ec /worktree_test.go
parentb30763cb64afa91c016b23e905af0a378eb1b76d (diff)
downloadgo-git-6b33126e79695b499d7d519f69db4ca1ebd22dd1.tar.gz
git: worktree, Skip special git directory. Fixes #814
Signed-off-by: kuba-- <kuba@sourced.tech>
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)
+}