aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-04-17 17:36:28 +0200
committerGitHub <noreply@github.com>2017-04-17 17:36:28 +0200
commitc991d2d1c2253ac246441bc92bf97804a73c0bf2 (patch)
tree9a6965fb0023262ea17d02bcedd9f48204a80750 /worktree_test.go
parent057f1dd4fa44df509cb96977c0a8193407a22767 (diff)
parent4b0fc1eb6937b6e5f8569794e8b669443e2c7584 (diff)
downloadgo-git-c991d2d1c2253ac246441bc92bf97804a73c0bf2.tar.gz
Merge pull request #344 from mcuadros/submodules-checkout
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")
}