Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit ac19b28

Browse files
committed
dotgit: support reading reference files in Windows
1 parent 1d846e8 commit ac19b28

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

storage/filesystem/internal/dotgit/dotgit.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ func (d *DotGit) processLine(line string) (*plumbing.Reference, error) {
386386
}
387387

388388
func (d *DotGit) addRefsFromRefDir(refs *[]*plumbing.Reference) error {
389-
return d.walkReferencesTree(refs, refsPath)
389+
return d.walkReferencesTree(refs, []string{refsPath})
390390
}
391391

392-
func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string) error {
393-
files, err := d.fs.ReadDir(relPath)
392+
func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath []string) error {
393+
files, err := d.fs.ReadDir(d.fs.Join(relPath...))
394394
if err != nil {
395395
if os.IsNotExist(err) {
396396
return nil
@@ -400,7 +400,7 @@ func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string)
400400
}
401401

402402
for _, f := range files {
403-
newRelPath := d.fs.Join(relPath, f.Name())
403+
newRelPath := append(append([]string(nil), relPath...), f.Name())
404404
if f.IsDir() {
405405
if err = d.walkReferencesTree(refs, newRelPath); err != nil {
406406
return err
@@ -409,7 +409,7 @@ func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string)
409409
continue
410410
}
411411

412-
ref, err := d.readReferenceFile(".", newRelPath)
412+
ref, err := d.readReferenceFile(".", strings.Join(newRelPath, "/"))
413413
if err != nil {
414414
return err
415415
}
@@ -436,9 +436,8 @@ func (d *DotGit) addRefFromHEAD(refs *[]*plumbing.Reference) error {
436436
return nil
437437
}
438438

439-
func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Reference, err error) {
440-
path := d.fs.Join(refsPath, refFile)
441-
439+
func (d *DotGit) readReferenceFile(path, name string) (ref *plumbing.Reference, err error) {
440+
path = d.fs.Join(path, d.fs.Join(strings.Split(name, "/")...))
442441
f, err := d.fs.Open(path)
443442
if err != nil {
444443
return nil, err
@@ -451,7 +450,7 @@ func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Refe
451450
}
452451

453452
line := strings.TrimSpace(string(b))
454-
return plumbing.NewReferenceFromStrings(refFile, line), nil
453+
return plumbing.NewReferenceFromStrings(name, line), nil
455454
}
456455

457456
// Module return a billy.Filesystem poiting to the module folder

0 commit comments

Comments
 (0)