aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-19 01:26:16 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-07-19 01:26:16 +0200
commit8210c82bcd6ff7f7c66b8f5fc1be00307fe59c42 (patch)
tree8b6fbb9401c43133dfac280eb36ea49df6d26e10
parentacb1a5f7a47e4759bbe1592a0a58571bda6289e7 (diff)
downloadgo-git-8210c82bcd6ff7f7c66b8f5fc1be00307fe59c42.tar.gz
utils: merkletrie filesystem based on path, and not in filepath
-rw-r--r--utils/merkletrie/filesystem/node.go6
-rw-r--r--utils/merkletrie/filesystem/node_test.go4
-rw-r--r--utils/merkletrie/index/node.go18
3 files changed, 14 insertions, 14 deletions
diff --git a/utils/merkletrie/filesystem/node.go b/utils/merkletrie/filesystem/node.go
index a8f3b86..f763e08 100644
--- a/utils/merkletrie/filesystem/node.go
+++ b/utils/merkletrie/filesystem/node.go
@@ -3,7 +3,7 @@ package filesystem
import (
"io"
"os"
- "path/filepath"
+ "path"
"gopkg.in/src-d/go-billy.v3"
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -53,7 +53,7 @@ func (n *node) Hash() []byte {
}
func (n *node) Name() string {
- return filepath.Base(n.path)
+ return path.Base(n.path)
}
func (n *node) IsDir() bool {
@@ -107,7 +107,7 @@ func (n *node) calculateChildren() error {
}
func (n *node) newChildNode(file os.FileInfo) (*node, error) {
- path := filepath.Join(n.path, file.Name())
+ path := path.Join(n.path, file.Name())
hash, err := n.calculateHash(path, file)
if err != nil {
diff --git a/utils/merkletrie/filesystem/node_test.go b/utils/merkletrie/filesystem/node_test.go
index 6d764ab..42dd82e 100644
--- a/utils/merkletrie/filesystem/node_test.go
+++ b/utils/merkletrie/filesystem/node_test.go
@@ -4,7 +4,7 @@ import (
"bytes"
"io"
"os"
- "path/filepath"
+ "path"
"testing"
. "gopkg.in/check.v1"
@@ -134,7 +134,7 @@ func (s *NoderSuite) TestDiffChangeModeNotRelevant(c *C) {
}
func (s *NoderSuite) TestDiffDirectory(c *C) {
- dir := filepath.Join("qux", "bar")
+ dir := path.Join("qux", "bar")
fsA := memfs.New()
fsA.MkdirAll(dir, 0644)
diff --git a/utils/merkletrie/index/node.go b/utils/merkletrie/index/node.go
index 859c097..9622622 100644
--- a/utils/merkletrie/index/node.go
+++ b/utils/merkletrie/index/node.go
@@ -1,7 +1,7 @@
package index
import (
- "path/filepath"
+ "path"
"strings"
"gopkg.in/src-d/go-git.v4/plumbing/format/index"
@@ -28,19 +28,19 @@ func NewRootNode(idx *index.Index) noder.Noder {
m := map[string]*node{rootNode: {isDir: true}}
for _, e := range idx.Entries {
- parts := strings.Split(e.Name, string(filepath.Separator))
+ parts := strings.Split(e.Name, string("/"))
- var path string
+ var fullpath string
for _, part := range parts {
- parent := path
- path = filepath.Join(path, part)
+ parent := fullpath
+ fullpath = path.Join(fullpath, part)
- if _, ok := m[path]; ok {
+ if _, ok := m[fullpath]; ok {
continue
}
- n := &node{path: path}
- if path == e.Name {
+ n := &node{path: fullpath}
+ if fullpath == e.Name {
n.entry = e
} else {
n.isDir = true
@@ -74,7 +74,7 @@ func (n *node) Hash() []byte {
}
func (n *node) Name() string {
- return filepath.Base(n.path)
+ return path.Base(n.path)
}
func (n *node) IsDir() bool {