diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d07a8d7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +language: go +go: + - 1.6 + - 1.5.3 + +sudo: false + +before_install: + - git config --global url."https://".insteadOf git:// + - go get golang.org/x/tools/cmd/vet + - go get -u github.com/golang/lint/golint + - mkdir -p $GOPATH/src/github.com/vbatts && ln -sf $(pwd) $GOPATH/src/github.com/vbatts/go-mtree + - go get ./... + +install: true + +script: + - go vet -x ./... + - golint ./... + - go test -v ./... diff --git a/hierarchy.go b/hierarchy.go index 3c70b5e..b591773 100644 --- a/hierarchy.go +++ b/hierarchy.go @@ -49,9 +49,9 @@ type Entry struct { // Path provides the full path of the file, despite RelativeType or FullType func (e Entry) Path() string { if e.Parent == nil || e.Type == FullType { - return e.Name + return filepath.Clean(e.Name) } - return filepath.Join(e.Parent.Path(), e.Name) + return filepath.Clean(filepath.Join(e.Parent.Path(), e.Name)) } func (e Entry) String() string { diff --git a/parse.go b/parse.go index 61af381..826e174 100644 --- a/parse.go +++ b/parse.go @@ -3,6 +3,7 @@ package mtree import ( "bufio" "io" + "path/filepath" "strings" ) @@ -70,12 +71,12 @@ func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) { } // parse the options f := strings.Fields(str) - if strings.Contains(str, "/") { + e.Name = filepath.Clean(f[0]) + if strings.Contains(e.Name, "/") { e.Type = FullType } else { e.Type = RelativeType } - e.Name = f[0] e.Keywords = f[1:] e.Parent = creator.curDir for i := range e.Keywords { diff --git a/walk.go b/walk.go index 2011a6a..ee2c3ea 100644 --- a/walk.go +++ b/walk.go @@ -42,7 +42,7 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie Pos: len(creator.DH.Entries), }) - // TODO Insert a comment of the full path of the directory's name + // Insert a comment of the full path of the directory's name if creator.curDir != nil { creator.DH.Entries = append(creator.DH.Entries, Entry{ Pos: len(creator.DH.Entries), diff --git a/xattr/xattr_test.go b/xattr/xattr_test.go index ae8f616..42cce6c 100644 --- a/xattr/xattr_test.go +++ b/xattr/xattr_test.go @@ -26,7 +26,7 @@ func TestXattr(t *testing.T) { t.Error(fh.Name(), err) } if !(len(l) > 0) { - t.Errorf("%q: expected a list of at least 1; got %d", len(l)) + t.Errorf("%q: expected a list of at least 1; got %d", fh.Name(), len(l)) } got, err := Get(fh.Name(), "user.testing") if err != nil {