From 410c0d60c1fce4af047fcc8a306797e7af38fcb9 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Wed, 13 Apr 2016 13:55:34 -0400 Subject: [PATCH] walk: when directory is root, use "." Signed-off-by: Vincent Batts --- walk.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/walk.go b/walk.go index ee2c3ea..a1ef434 100644 --- a/walk.go +++ b/walk.go @@ -36,6 +36,7 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie } } + entryPathName := filepath.Base(path) if info.IsDir() { creator.DH.Entries = append(creator.DH.Entries, Entry{ Type: BlankType, @@ -46,13 +47,14 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie if creator.curDir != nil { creator.DH.Entries = append(creator.DH.Entries, Entry{ Pos: len(creator.DH.Entries), - Raw: "# " + filepath.Join(creator.curDir.Path(), filepath.Base(path)), + Raw: "# " + filepath.Join(creator.curDir.Path(), entryPathName), Type: CommentType, }) } else { + entryPathName = "." creator.DH.Entries = append(creator.DH.Entries, Entry{ Pos: len(creator.DH.Entries), - Raw: "# " + filepath.Base(path), + Raw: "# .", Type: CommentType, }) } @@ -105,7 +107,7 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie } e := Entry{ - Name: filepath.Base(path), + Name: entryPathName, Pos: len(creator.DH.Entries), Type: RelativeType, Set: creator.curSet,