@@ -2,9 +2,7 @@ package gitbase
22
33import (
44 "io"
5- stdioutil "io/ioutil"
65 "os"
7- "path/filepath"
86
97 errors "gopkg.in/src-d/go-errors.v1"
108 "gopkg.in/src-d/go-git.v4/plumbing/object"
@@ -13,9 +11,7 @@ import (
1311 "gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit"
1412 "gopkg.in/src-d/go-git.v4/utils/ioutil"
1513
16- "gopkg.in/src-d/go-billy-siva.v4"
1714 billy "gopkg.in/src-d/go-billy.v4"
18- "gopkg.in/src-d/go-billy.v4/osfs"
1915 "gopkg.in/src-d/go-git.v4/plumbing"
2016 "gopkg.in/src-d/go-git.v4/plumbing/format/idxfile"
2117 "gopkg.in/src-d/go-git.v4/plumbing/format/objfile"
@@ -26,8 +22,8 @@ type packRepository struct {
2622 packs map [plumbing.Hash ]packfile.Index
2723}
2824
29- func repositoryPackfiles (path string , kind repoKind ) (* dotgit.DotGit , []plumbing.Hash , error ) {
30- fs , err := repoFilesystem ( path , kind )
25+ func repositoryPackfiles (repo repository ) (* dotgit.DotGit , []plumbing.Hash , error ) {
26+ fs , err := repo . FS ( )
3127 if err != nil {
3228 return nil , nil , err
3329 }
@@ -56,8 +52,8 @@ type repositoryIndex struct {
5652 indexes []* packfileIndex
5753}
5854
59- func newRepositoryIndex (path string , kind repoKind ) (* repositoryIndex , error ) {
60- dot , packfiles , err := repositoryPackfiles (path , kind )
55+ func newRepositoryIndex (repo repository ) (* repositoryIndex , error ) {
56+ dot , packfiles , err := repositoryPackfiles (repo )
6157 if err != nil {
6258 return nil , err
6359 }
@@ -126,23 +122,6 @@ func (i *repositoryIndex) isUnpacked(hash plumbing.Hash) (bool, error) {
126122 return true , nil
127123}
128124
129- func repoFilesystem (path string , kind repoKind ) (billy.Filesystem , error ) {
130- if kind == sivaRepo {
131- localfs := osfs .New (filepath .Dir (path ))
132-
133- tmpDir , err := stdioutil .TempDir (os .TempDir (), "gitbase-siva" )
134- if err != nil {
135- return nil , err
136- }
137-
138- tmpfs := osfs .New (tmpDir )
139-
140- return sivafs .NewFilesystem (localfs , filepath .Base (path ), tmpfs )
141- }
142-
143- return osfs .New (path ), nil
144- }
145-
146125func findDotGit (fs billy.Filesystem ) (billy.Filesystem , error ) {
147126 fi , err := fs .Stat (".git" )
148127 if err != nil && ! os .IsNotExist (err ) {
@@ -157,7 +136,7 @@ func findDotGit(fs billy.Filesystem) (billy.Filesystem, error) {
157136}
158137
159138func getUnpackedObject (repo repository , hash plumbing.Hash ) (o object.Object , err error ) {
160- fs , err := repoFilesystem ( repo .path , repo . kind )
139+ fs , err := repo .FS ( )
161140 if err != nil {
162141 return nil , err
163142 }
@@ -222,7 +201,7 @@ func newRepoObjectDecoder(
222201 repo repository ,
223202 hash plumbing.Hash ,
224203) (* repoObjectDecoder , error ) {
225- fs , err := repoFilesystem ( repo .path , repo . kind )
204+ fs , err := repo .FS ( )
226205 if err != nil {
227206 return nil , err
228207 }
@@ -251,7 +230,7 @@ func newRepoObjectDecoder(
251230 }
252231
253232 return & repoObjectDecoder {
254- repo : repo .path ,
233+ repo : repo .Path () ,
255234 packfile : hash ,
256235 decoder : decoder ,
257236 storage : storage ,
0 commit comments