diff options
author | Sunny <me@darkowlzz.space> | 2017-12-06 18:51:56 +0530 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-12-06 14:21:56 +0100 |
commit | eb74b0e1a0ae20075435aded41bffc522bc3554c (patch) | |
tree | 573952f76c2c311d1cf0cbf7627c6af4a68071dc /worktree_test.go | |
parent | f96d46d38f67604f204711ea0e2832e6e047e2ad (diff) | |
download | go-git-eb74b0e1a0ae20075435aded41bffc522bc3554c.tar.gz |
storage: filesystem, add support for git alternates (#663)
This change adds a new method Alternates() in DotGit to check and
query alternate source.
Diffstat (limited to 'worktree_test.go')
-rw-r--r-- | worktree_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go index 46c1faa..4f24cff 100644 --- a/worktree_test.go +++ b/worktree_test.go @@ -1287,3 +1287,33 @@ func (s *WorktreeSuite) TestClean(c *C) { c.Assert(len(status), Equals, 0) } + +func (s *WorktreeSuite) TestAlternatesRepo(c *C) { + fs := fixtures.ByTag("alternates").One().Worktree() + + // Open 1st repo. + rep1fs, err := fs.Chroot("rep1") + c.Assert(err, IsNil) + rep1, err := PlainOpen(rep1fs.Root()) + c.Assert(err, IsNil) + + // Open 2nd repo. + rep2fs, err := fs.Chroot("rep2") + c.Assert(err, IsNil) + rep2, err := PlainOpen(rep2fs.Root()) + c.Assert(err, IsNil) + + // Get the HEAD commit from the main repo. + h, err := rep1.Head() + c.Assert(err, IsNil) + commit1, err := rep1.CommitObject(h.Hash()) + c.Assert(err, IsNil) + + // Get the HEAD commit from the shared repo. + h, err = rep2.Head() + c.Assert(err, IsNil) + commit2, err := rep2.CommitObject(h.Hash()) + c.Assert(err, IsNil) + + c.Assert(commit1.String(), Equals, commit2.String()) +} |