(c *C)
| 675 | } |
| 676 | |
| 677 | func (s *WorktreeSuite) TestCheckoutRelativePathSubmoduleInitialized(c *C) { |
| 678 | url := "https://github.com/git-fixtures/submodule.git" |
| 679 | r := s.NewRepository(fixtures.ByURL(url).One()) |
| 680 | |
| 681 | // modify the .gitmodules from original one |
| 682 | file, err := r.wt.OpenFile(".gitmodules", os.O_WRONLY|os.O_TRUNC, 0666) |
| 683 | c.Assert(err, IsNil) |
| 684 | |
| 685 | n, err := io.WriteString(file, `[submodule "basic"] |
| 686 | path = basic |
| 687 | url = ../basic.git |
| 688 | [submodule "itself"] |
| 689 | path = itself |
| 690 | url = ../submodule.git`) |
| 691 | c.Assert(err, IsNil) |
| 692 | c.Assert(n, Not(Equals), 0) |
| 693 | |
| 694 | w, err := r.Worktree() |
| 695 | c.Assert(err, IsNil) |
| 696 | |
| 697 | w.Add(".gitmodules") |
| 698 | w.Commit("test", &CommitOptions{}) |
| 699 | |
| 700 | // test submodule path |
| 701 | modules, err := w.readGitmodulesFile() |
| 702 | c.Assert(err, IsNil) |
| 703 | |
| 704 | c.Assert(modules.Submodules["basic"].URL, Equals, "../basic.git") |
| 705 | c.Assert(modules.Submodules["itself"].URL, Equals, "../submodule.git") |
| 706 | |
| 707 | basicSubmodule, err := w.Submodule("basic") |
| 708 | c.Assert(err, IsNil) |
| 709 | basicRepo, err := basicSubmodule.Repository() |
| 710 | c.Assert(err, IsNil) |
| 711 | basicRemotes, err := basicRepo.Remotes() |
| 712 | c.Assert(err, IsNil) |
| 713 | c.Assert(basicRemotes[0].Config().URLs[0], Equals, "https://github.com/git-fixtures/basic.git") |
| 714 | |
| 715 | itselfSubmodule, err := w.Submodule("itself") |
| 716 | c.Assert(err, IsNil) |
| 717 | itselfRepo, err := itselfSubmodule.Repository() |
| 718 | c.Assert(err, IsNil) |
| 719 | itselfRemotes, err := itselfRepo.Remotes() |
| 720 | c.Assert(err, IsNil) |
| 721 | c.Assert(itselfRemotes[0].Config().URLs[0], Equals, "https://github.com/git-fixtures/submodule.git") |
| 722 | |
| 723 | sub, err := w.Submodules() |
| 724 | c.Assert(err, IsNil) |
| 725 | |
| 726 | err = sub.Update(&SubmoduleUpdateOptions{Init: true, RecurseSubmodules: DefaultSubmoduleRecursionDepth}) |
| 727 | c.Assert(err, IsNil) |
| 728 | |
| 729 | status, err := w.Status() |
| 730 | c.Assert(err, IsNil) |
| 731 | c.Assert(status.IsClean(), Equals, true) |
| 732 | } |
| 733 | |
| 734 | func (s *WorktreeSuite) TestCheckoutIndexMem(c *C) { |
nothing calls this directly
no test coverage detected