aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-04-15 23:13:45 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-04-15 23:13:45 +0200
commit4b0fc1eb6937b6e5f8569794e8b669443e2c7584 (patch)
tree9f2fdb086be2b96ff9c2169fdb93e19e5a298490 /worktree_test.go
parent601c85a8834cd78e317f1ba435475fa18162053a (diff)
downloadgo-git-4b0fc1eb6937b6e5f8569794e8b669443e2c7584.tar.gz
worktree: reset and checkout support for submodules
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go45
1 files changed, 44 insertions, 1 deletions
diff --git a/worktree_test.go b/worktree_test.go
index 59197a6..3393469 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -54,6 +54,48 @@ func (s *WorktreeSuite) TestCheckout(c *C) {
c.Assert(idx.Entries, HasLen, 9)
}
+func (s *WorktreeSuite) TestCheckoutSubmodule(c *C) {
+ url := "https://github.com/git-fixtures/submodule.git"
+ w := &Worktree{
+ r: s.NewRepository(fixtures.ByURL(url).One()),
+ fs: memfs.New(),
+ }
+
+ // we delete the index, since the fixture comes with a real index
+ err := w.r.Storer.SetIndex(&index.Index{Version: 2})
+ c.Assert(err, IsNil)
+
+ err = w.Checkout(&CheckoutOptions{})
+ c.Assert(err, IsNil)
+
+ status, err := w.Status()
+ c.Assert(err, IsNil)
+ c.Assert(status.IsClean(), Equals, true)
+}
+
+func (s *WorktreeSuite) TestCheckoutSubmoduleInitialized(c *C) {
+ url := "https://github.com/git-fixtures/submodule.git"
+ w := &Worktree{
+ r: s.NewRepository(fixtures.ByURL(url).One()),
+ fs: memfs.New(),
+ }
+
+ err := w.r.Storer.SetIndex(&index.Index{Version: 2})
+ c.Assert(err, IsNil)
+
+ err = w.Checkout(&CheckoutOptions{})
+ c.Assert(err, IsNil)
+ sub, err := w.Submodules()
+ c.Assert(err, IsNil)
+
+ err = sub.Update(&SubmoduleUpdateOptions{Init: true})
+ c.Assert(err, IsNil)
+
+ status, err := w.Status()
+ c.Assert(err, IsNil)
+ c.Assert(status.IsClean(), Equals, true)
+}
+
func (s *WorktreeSuite) TestCheckoutIndexMem(c *C) {
fs := memfs.New()
w := &Worktree{
@@ -119,6 +161,7 @@ func (s *WorktreeSuite) TestCheckoutChange(c *C) {
err := w.Checkout(&CheckoutOptions{})
c.Assert(err, IsNil)
+
head, err := w.r.Head()
c.Assert(err, IsNil)
c.Assert(head.Name().String(), Equals, "refs/heads/master")
@@ -143,6 +186,7 @@ func (s *WorktreeSuite) TestCheckoutChange(c *C) {
_, err = fs.Stat("README")
c.Assert(err, Equals, nil)
+
_, err = fs.Stat("vendor")
c.Assert(err, Equals, os.ErrNotExist)
@@ -200,7 +244,6 @@ func (s *WorktreeSuite) TestCheckoutBisect(c *C) {
}
func (s *WorktreeSuite) TestCheckoutBisectSubmodules(c *C) {
- c.Skip("not-submodule-support")
s.testCheckoutBisect(c, "https://github.com/git-fixtures/submodule.git")
}