@@ -10,7 +10,8 @@ import (
10
10
"strings"
11
11
12
12
"gopkg.in/src-d/go-git.v4/plumbing"
13
- "gopkg.in/src-d/go-git.v4/utils/fs"
13
+
14
+ "srcd.works/go-billy.v1"
14
15
)
15
16
16
17
const (
@@ -51,33 +52,33 @@ var (
51
52
// The DotGit type represents a local git repository on disk. This
52
53
// type is not zero-value-safe, use the New function to initialize it.
53
54
type DotGit struct {
54
- fs fs .Filesystem
55
+ fs billy .Filesystem
55
56
}
56
57
57
58
// New returns a DotGit value ready to be used. The path argument must
58
59
// be the absolute path of a git repository directory (e.g.
59
60
// "/foo/bar/.git").
60
- func New (fs fs .Filesystem ) * DotGit {
61
+ func New (fs billy .Filesystem ) * DotGit {
61
62
return & DotGit {fs : fs }
62
63
}
63
64
64
65
// ConfigWriter returns a file pointer for write to the config file
65
- func (d * DotGit ) ConfigWriter () (fs .File , error ) {
66
+ func (d * DotGit ) ConfigWriter () (billy .File , error ) {
66
67
return d .fs .Create (configPath )
67
68
}
68
69
69
70
// Config returns a file pointer for read to the config file
70
- func (d * DotGit ) Config () (fs .File , error ) {
71
+ func (d * DotGit ) Config () (billy .File , error ) {
71
72
return d .fs .Open (configPath )
72
73
}
73
74
74
75
// ShallowWriter returns a file pointer for write to the shallow file
75
- func (d * DotGit ) ShallowWriter () (fs .File , error ) {
76
+ func (d * DotGit ) ShallowWriter () (billy .File , error ) {
76
77
return d .fs .Create (shallowPath )
77
78
}
78
79
79
80
// Shallow returns a file pointer for read to the shallow file
80
- func (d * DotGit ) Shallow () (fs .File , error ) {
81
+ func (d * DotGit ) Shallow () (billy .File , error ) {
81
82
f , err := d .fs .Open (shallowPath )
82
83
if err != nil {
83
84
if os .IsNotExist (err ) {
@@ -124,7 +125,7 @@ func (d *DotGit) ObjectPacks() ([]plumbing.Hash, error) {
124
125
}
125
126
126
127
// ObjectPack returns a fs.File of the given packfile
127
- func (d * DotGit ) ObjectPack (hash plumbing.Hash ) (fs .File , error ) {
128
+ func (d * DotGit ) ObjectPack (hash plumbing.Hash ) (billy .File , error ) {
128
129
file := d .fs .Join (objectsPath , packPath , fmt .Sprintf ("pack-%s.pack" , hash .String ()))
129
130
130
131
pack , err := d .fs .Open (file )
@@ -140,7 +141,7 @@ func (d *DotGit) ObjectPack(hash plumbing.Hash) (fs.File, error) {
140
141
}
141
142
142
143
// ObjectPackIdx returns a fs.File of the index file for a given packfile
143
- func (d * DotGit ) ObjectPackIdx (hash plumbing.Hash ) (fs .File , error ) {
144
+ func (d * DotGit ) ObjectPackIdx (hash plumbing.Hash ) (billy .File , error ) {
144
145
file := d .fs .Join (objectsPath , packPath , fmt .Sprintf ("pack-%s.idx" , hash .String ()))
145
146
idx , err := d .fs .Open (file )
146
147
if err != nil {
@@ -190,7 +191,7 @@ func (d *DotGit) Objects() ([]plumbing.Hash, error) {
190
191
}
191
192
192
193
// Object return a fs.File poiting the object file, if exists
193
- func (d * DotGit ) Object (h plumbing.Hash ) (fs .File , error ) {
194
+ func (d * DotGit ) Object (h plumbing.Hash ) (billy .File , error ) {
194
195
hash := h .String ()
195
196
file := d .fs .Join (objectsPath , hash [0 :2 ], hash [2 :40 ])
196
197
0 commit comments