aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorPaulo Gomes <paulo.gomes@suse.com>2023-12-02 10:30:30 +0000
committerPaulo Gomes <paulo.gomes@suse.com>2023-12-02 10:30:39 +0000
commit8b47ceb1aa854f3c3bfa1c347157a04324fcd51e (patch)
tree4bb09922af1faa0caca922f0e22f5ba341c970e2 /worktree_test.go
parent4f614891047bae5d0f7a253f014175505b9821d7 (diff)
downloadgo-git-8b47ceb1aa854f3c3bfa1c347157a04324fcd51e.tar.gz
storage: filesystem, Add option to set a specific FS for alternates
Introduces the option to set a FS for alternates, enabling more flexible cross FS sharing of alternates. If none is set, falls back to the current FS used for the object storage. The changes only process a given path once, and if an alternates dir is not valid, exits with error - aligning behaviour with upstream. Signed-off-by: Paulo Gomes <paulo.gomes@suse.com>
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/worktree_test.go b/worktree_test.go
index 3136e59..3e057a7 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -16,11 +16,14 @@ import (
fixtures "github.com/go-git/go-git-fixtures/v4"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
+ "github.com/go-git/go-git/v5/plumbing/cache"
"github.com/go-git/go-git/v5/plumbing/filemode"
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
"github.com/go-git/go-git/v5/plumbing/format/index"
"github.com/go-git/go-git/v5/plumbing/object"
+ "github.com/go-git/go-git/v5/storage/filesystem"
"github.com/go-git/go-git/v5/storage/memory"
+ "github.com/stretchr/testify/assert"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-billy/v5/osfs"
@@ -2198,34 +2201,40 @@ func (s *WorktreeSuite) TestCleanBare(c *C) {
c.Assert(err, IsNil)
}
-func (s *WorktreeSuite) TestAlternatesRepo(c *C) {
+func TestAlternatesRepo(t *testing.T) {
fs := fixtures.ByTag("alternates").One().Worktree()
// Open 1st repo.
rep1fs, err := fs.Chroot("rep1")
- c.Assert(err, IsNil)
+ assert.NoError(t, err)
rep1, err := PlainOpen(rep1fs.Root())
- c.Assert(err, IsNil)
+ assert.NoError(t, err)
// Open 2nd repo.
rep2fs, err := fs.Chroot("rep2")
- c.Assert(err, IsNil)
- rep2, err := PlainOpen(rep2fs.Root())
- c.Assert(err, IsNil)
+ assert.NoError(t, err)
+ d, _ := rep2fs.Chroot(GitDirName)
+ storer := filesystem.NewStorageWithOptions(d,
+ cache.NewObjectLRUDefault(), filesystem.Options{
+ AlternatesFS: fs,
+ })
+ rep2, err := Open(storer, rep2fs)
+
+ assert.NoError(t, err)
// Get the HEAD commit from the main repo.
h, err := rep1.Head()
- c.Assert(err, IsNil)
+ assert.NoError(t, err)
commit1, err := rep1.CommitObject(h.Hash())
- c.Assert(err, IsNil)
+ assert.NoError(t, err)
// Get the HEAD commit from the shared repo.
h, err = rep2.Head()
- c.Assert(err, IsNil)
+ assert.NoError(t, err)
commit2, err := rep2.CommitObject(h.Hash())
- c.Assert(err, IsNil)
+ assert.NoError(t, err)
- c.Assert(commit1.String(), Equals, commit2.String())
+ assert.Equal(t, commit1.String(), commit2.String())
}
func (s *WorktreeSuite) TestGrep(c *C) {