From 756fe0c2e49d7a1d5de849026d3843b880b46a4d Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Fri, 28 Apr 2017 17:35:41 +0200 Subject: test: more Windows path handling --- storage/filesystem/internal/dotgit/dotgit_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'storage') diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go index f06f908..e1667af 100644 --- a/storage/filesystem/internal/dotgit/dotgit_test.go +++ b/storage/filesystem/internal/dotgit/dotgit_test.go @@ -445,7 +445,7 @@ func (s *SuiteDotGit) TestObject(c *C) { file, err := dir.Object(hash) c.Assert(err, IsNil) c.Assert(strings.HasSuffix( - file.Filename(), "objects/03/db8e1fbe133a480f2867aac478fd866686d69e"), + file.Filename(), fs.Join("objects", "03", "db8e1fbe133a480f2867aac478fd866686d69e")), Equals, true, ) } @@ -465,5 +465,5 @@ func (s *SuiteDotGit) TestSubmodules(c *C) { dir := New(fs) m := dir.Module("basic") - c.Assert(strings.HasSuffix(m.Base(), ".git/module/basic"), Equals, true) + c.Assert(strings.HasSuffix(m.Base(), m.Join(".git", "module", "basic")), Equals, true) } -- cgit From aba32ceed59d77c84038fa421b230e1ea76a5e6b Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Fri, 28 Apr 2017 17:50:36 +0200 Subject: dotgit: support reading reference files in Windows --- storage/filesystem/internal/dotgit/dotgit.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'storage') diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go index f9f4d79..7db5aa6 100644 --- a/storage/filesystem/internal/dotgit/dotgit.go +++ b/storage/filesystem/internal/dotgit/dotgit.go @@ -413,11 +413,11 @@ func (d *DotGit) processLine(line string) (*plumbing.Reference, error) { } func (d *DotGit) addRefsFromRefDir(refs *[]*plumbing.Reference) error { - return d.walkReferencesTree(refs, refsPath) + return d.walkReferencesTree(refs, []string{refsPath}) } -func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string) error { - files, err := d.fs.ReadDir(relPath) +func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath []string) error { + files, err := d.fs.ReadDir(d.fs.Join(relPath...)) if err != nil { if os.IsNotExist(err) { return nil @@ -427,7 +427,7 @@ func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string) } for _, f := range files { - newRelPath := d.fs.Join(relPath, f.Name()) + newRelPath := append(append([]string(nil), relPath...), f.Name()) if f.IsDir() { if err = d.walkReferencesTree(refs, newRelPath); err != nil { return err @@ -436,7 +436,7 @@ func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string) continue } - ref, err := d.readReferenceFile(".", newRelPath) + ref, err := d.readReferenceFile(".", strings.Join(newRelPath, "/")) if err != nil { return err } @@ -463,9 +463,8 @@ func (d *DotGit) addRefFromHEAD(refs *[]*plumbing.Reference) error { return nil } -func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Reference, err error) { - path := d.fs.Join(refsPath, refFile) - +func (d *DotGit) readReferenceFile(path, name string) (ref *plumbing.Reference, err error) { + path = d.fs.Join(path, d.fs.Join(strings.Split(name, "/")...)) f, err := d.fs.Open(path) if err != nil { return nil, err @@ -478,7 +477,7 @@ func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Refe } line := strings.TrimSpace(string(b)) - return plumbing.NewReferenceFromStrings(refFile, line), nil + return plumbing.NewReferenceFromStrings(name, line), nil } // Module return a billy.Filesystem poiting to the module folder -- cgit