From 30681d2f0a31a4e29ad3e877fb9f4298d0b2590b Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Thu, 24 Aug 2023 17:11:22 -0700 Subject: [PATCH] filelist/*: skip empty lines (MR 41) fixes #36 --- internal/filelist/hookdirs/hookdirs.go | 4 ++++ internal/filelist/hookfiles/hookfiles.go | 7 ++++++- internal/filelist/modules/modules.go | 11 ++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/internal/filelist/hookdirs/hookdirs.go b/internal/filelist/hookdirs/hookdirs.go index 8e46934..15eadbe 100644 --- a/internal/filelist/hookdirs/hookdirs.go +++ b/internal/filelist/hookdirs/hookdirs.go @@ -44,6 +44,10 @@ func (h *HookDirs) List() (*filelist.FileList, error) { s := bufio.NewScanner(f) for s.Scan() { dir := s.Text() + if len(dir) == 0 { + continue + } + files.Add(dir, dir) } } diff --git a/internal/filelist/hookfiles/hookfiles.go b/internal/filelist/hookfiles/hookfiles.go index e87ed27..748ffe7 100644 --- a/internal/filelist/hookfiles/hookfiles.go +++ b/internal/filelist/hookfiles/hookfiles.go @@ -58,7 +58,12 @@ func slurpFiles(fd io.Reader) (*filelist.FileList, error) { s := bufio.NewScanner(fd) for s.Scan() { - src, dest, has_dest := strings.Cut(s.Text(), ":") + line := s.Text() + if len(line) == 0 { + continue + } + + src, dest, has_dest := strings.Cut(line, ":") fFiles, err := misc.GetFiles([]string{src}, true) if err != nil { diff --git a/internal/filelist/modules/modules.go b/internal/filelist/modules/modules.go index 7da47aa..4fa51f7 100644 --- a/internal/filelist/modules/modules.go +++ b/internal/filelist/modules/modules.go @@ -95,6 +95,10 @@ func slurpModules(fd io.Reader, modDir string) (*filelist.FileList, error) { s := bufio.NewScanner(fd) for s.Scan() { line := s.Text() + if len(line) == 0 { + continue + } + dir, file := filepath.Split(line) if file == "" { // item is a directory @@ -194,7 +198,12 @@ func getModuleDeps(modName string, modulesDep io.Reader) ([]string, error) { s := bufio.NewScanner(modulesDep) for s.Scan() { - fields := strings.Fields(s.Text()) + line := s.Text() + if len(line) == 0 { + continue + } + + fields := strings.Fields(line) if len(fields) == 0 { continue }