aboutsummaryrefslogtreecommitdiffstats
path: root/fixtures/fixtures.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-09 16:50:35 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-09 16:50:35 +0200
commitf09fb50cb092c241df4c0bd25c6755e6132e473e (patch)
treec67f4cdeacf70a64d00167cceceed7a68a5c9e4a /fixtures/fixtures.go
parent59219f01bbf5f748876258fe5f4648d2cfd4d6e9 (diff)
downloadgo-git-f09fb50cb092c241df4c0bd25c6755e6132e473e.tar.gz
storage: filessytem read multiple packfiles support and index decoding
Diffstat (limited to 'fixtures/fixtures.go')
-rw-r--r--fixtures/fixtures.go33
1 files changed, 32 insertions, 1 deletions
diff --git a/fixtures/fixtures.go b/fixtures/fixtures.go
index 2065038..7b72650 100644
--- a/fixtures/fixtures.go
+++ b/fixtures/fixtures.go
@@ -6,8 +6,11 @@ import (
"os"
"path/filepath"
+ "github.com/alcortesm/tgz"
+
check "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v4/core"
+ "gopkg.in/src-d/go-git.v4/utils/fs"
)
var RootFolder = ""
@@ -15,16 +18,21 @@ var RootFolder = ""
const DataFolder = "data"
var fixtures = []*Fixture{{
- Tags: []string{"ofs-delta"},
+ Tags: []string{"ofs-delta", ".git"},
URL: "https://github.com/git-fixtures/basic",
Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
PackfileHash: core.NewHash("a3fed42da1e8189a077c0e6846c040dcf73fc9dd"),
+ DotGitHash: core.NewHash("0a00a25543e6d732dbf4e8e9fec55c8e65fc4e8d"),
}, {
Tags: []string{"ref-delta"},
URL: "https://github.com/git-fixtures/basic",
Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
PackfileHash: core.NewHash("c544593473465e6315ad4182d04d366c4592b829"),
}, {
+ Tags: []string{".git", "unpacked", "multi-packfile"},
+ URL: "https://github.com/src-d/go-git.git",
+ DotGitHash: core.NewHash("174be6bd4292c18160542ae6dc6704b877b8a01a"),
+}, {
URL: "https://github.com/spinnaker/spinnaker",
Head: core.NewHash("06ce06d0fc49646c4de733c45b7788aabad98a6f"),
PackfileHash: core.NewHash("f2e0a8889a746f7600e07d2246a2e29a72f696be"),
@@ -49,11 +57,25 @@ func ByURL(url string) Fixtures {
return r
}
+func ByTag(tag string) Fixtures {
+ r := make(Fixtures, 0)
+ for _, f := range fixtures {
+ for _, t := range f.Tags {
+ if t == tag {
+ r = append(r, f)
+ }
+ }
+ }
+
+ return r
+}
+
type Fixture struct {
URL string
Tags []string
Head core.Hash
PackfileHash core.Hash
+ DotGitHash core.Hash
}
func (f *Fixture) Packfile() io.ReadSeeker {
@@ -76,6 +98,15 @@ func (f *Fixture) Idx() io.ReadSeeker {
return file
}
+func (f *Fixture) DotGit() fs.Filesystem {
+ fn := filepath.Join(RootFolder, DataFolder, fmt.Sprintf("git-%s.tgz", f.DotGitHash))
+ path, err := tgz.Extract(fn)
+ if err != nil {
+ panic(err)
+ }
+ return fs.NewOS(path)
+}
+
type Fixtures []*Fixture
func (g Fixtures) Test(c *check.C, test func(*Fixture)) {