(c *C)
| 620 | } |
| 621 | |
| 622 | func (s *WorktreeSuite) TestCheckoutRelativePathSubmoduleInitialized(c *C) { |
| 623 | url := "https://github.com/git-fixtures/submodule.git" |
| 624 | r := s.NewRepository(fixtures.ByURL(url).One()) |
| 625 | |
| 626 | // modify the .gitmodules from original one |
| 627 | file, err := r.wt.OpenFile(".gitmodules", os.O_WRONLY|os.O_TRUNC, 0666) |
| 628 | c.Assert(err, IsNil) |
| 629 | |
| 630 | n, err := io.WriteString(file, `[submodule "basic"] |
| 631 | path = basic |
| 632 | url = ../basic.git |
| 633 | [submodule "itself"] |
| 634 | path = itself |
| 635 | url = ../submodule.git`) |
| 636 | c.Assert(err, IsNil) |
| 637 | c.Assert(n, Not(Equals), 0) |
| 638 | |
| 639 | w, err := r.Worktree() |
| 640 | c.Assert(err, IsNil) |
| 641 | |
| 642 | w.Add(".gitmodules") |
| 643 | w.Commit("test", &CommitOptions{}) |
| 644 | |
| 645 | // test submodule path |
| 646 | modules, err := w.readGitmodulesFile() |
| 647 | c.Assert(err, IsNil) |
| 648 | |
| 649 | c.Assert(modules.Submodules["basic"].URL, Equals, "../basic.git") |
| 650 | c.Assert(modules.Submodules["itself"].URL, Equals, "../submodule.git") |
| 651 | |
| 652 | basicSubmodule, err := w.Submodule("basic") |
| 653 | c.Assert(err, IsNil) |
| 654 | basicRepo, err := basicSubmodule.Repository() |
| 655 | c.Assert(err, IsNil) |
| 656 | basicRemotes, err := basicRepo.Remotes() |
| 657 | c.Assert(err, IsNil) |
| 658 | c.Assert(basicRemotes[0].Config().URLs[0], Equals, "https://github.com/git-fixtures/basic.git") |
| 659 | |
| 660 | itselfSubmodule, err := w.Submodule("itself") |
| 661 | c.Assert(err, IsNil) |
| 662 | itselfRepo, err := itselfSubmodule.Repository() |
| 663 | c.Assert(err, IsNil) |
| 664 | itselfRemotes, err := itselfRepo.Remotes() |
| 665 | c.Assert(err, IsNil) |
| 666 | c.Assert(itselfRemotes[0].Config().URLs[0], Equals, "https://github.com/git-fixtures/submodule.git") |
| 667 | |
| 668 | sub, err := w.Submodules() |
| 669 | c.Assert(err, IsNil) |
| 670 | |
| 671 | err = sub.Update(&SubmoduleUpdateOptions{Init: true, RecurseSubmodules: DefaultSubmoduleRecursionDepth}) |
| 672 | c.Assert(err, IsNil) |
| 673 | |
| 674 | status, err := w.Status() |
| 675 | c.Assert(err, IsNil) |
| 676 | c.Assert(status.IsClean(), Equals, true) |
| 677 | } |
| 678 | |
| 679 | func (s *WorktreeSuite) TestCheckoutIndexMem(c *C) { |
nothing calls this directly
no test coverage detected