mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-29 03:25:39 +00:00
commit
d3a4dc6d72
5 changed files with 27 additions and 6 deletions
20
.travis.yml
Normal file
20
.travis.yml
Normal file
|
@ -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 ./...
|
|
@ -49,9 +49,9 @@ type Entry struct {
|
||||||
// Path provides the full path of the file, despite RelativeType or FullType
|
// Path provides the full path of the file, despite RelativeType or FullType
|
||||||
func (e Entry) Path() string {
|
func (e Entry) Path() string {
|
||||||
if e.Parent == nil || e.Type == FullType {
|
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 {
|
func (e Entry) String() string {
|
||||||
|
|
5
parse.go
5
parse.go
|
@ -3,6 +3,7 @@ package mtree
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"io"
|
"io"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,12 +71,12 @@ func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) {
|
||||||
}
|
}
|
||||||
// parse the options
|
// parse the options
|
||||||
f := strings.Fields(str)
|
f := strings.Fields(str)
|
||||||
if strings.Contains(str, "/") {
|
e.Name = filepath.Clean(f[0])
|
||||||
|
if strings.Contains(e.Name, "/") {
|
||||||
e.Type = FullType
|
e.Type = FullType
|
||||||
} else {
|
} else {
|
||||||
e.Type = RelativeType
|
e.Type = RelativeType
|
||||||
}
|
}
|
||||||
e.Name = f[0]
|
|
||||||
e.Keywords = f[1:]
|
e.Keywords = f[1:]
|
||||||
e.Parent = creator.curDir
|
e.Parent = creator.curDir
|
||||||
for i := range e.Keywords {
|
for i := range e.Keywords {
|
||||||
|
|
2
walk.go
2
walk.go
|
@ -42,7 +42,7 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie
|
||||||
Pos: len(creator.DH.Entries),
|
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 {
|
if creator.curDir != nil {
|
||||||
creator.DH.Entries = append(creator.DH.Entries, Entry{
|
creator.DH.Entries = append(creator.DH.Entries, Entry{
|
||||||
Pos: len(creator.DH.Entries),
|
Pos: len(creator.DH.Entries),
|
||||||
|
|
|
@ -26,7 +26,7 @@ func TestXattr(t *testing.T) {
|
||||||
t.Error(fh.Name(), err)
|
t.Error(fh.Name(), err)
|
||||||
}
|
}
|
||||||
if !(len(l) > 0) {
|
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")
|
got, err := Get(fh.Name(), "user.testing")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue