From 67d84229a354287405c0d4e26a96d5fb38d60ef8 Mon Sep 17 00:00:00 2001 From: Bryan Hundven Date: Fri, 23 Jun 2023 11:34:02 -0700 Subject: [PATCH] Filter comments in the list file as well as empty lines. It's handy to have comments in the list file so that you describe to other teams that may have different destination repos where to put actions to sync. closes #106 Signed-off-by: Bryan Hundven --- src/reponames.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/reponames.go b/src/reponames.go index ae5212f0..c79f3e4e 100644 --- a/src/reponames.go +++ b/src/reponames.go @@ -62,7 +62,7 @@ func getRepoNamesFromCacheDir(flags *CommonFlags) ([]string, error) { } func getRepoNamesFromCSVString(csv string) ([]string, error) { - repos := filterEmptyEntries(strings.Split(csv, ",")) + repos := filterEntries(strings.Split(csv, ",")) if len(repos) == 0 { return nil, ErrEmptyRepoList } @@ -74,17 +74,17 @@ func getRepoNamesFromFile(file string) ([]string, error) { if err != nil { return nil, err } - repos := filterEmptyEntries(strings.Split(string(data), "\n")) + repos := filterEntries(strings.Split(string(data), "\n")) if len(repos) == 0 { return nil, ErrEmptyRepoList } return repos, nil } -func filterEmptyEntries(names []string) []string { +func filterEntries(names []string) []string { filtered := []string{} for _, name := range names { - if name != "" { + if !strings.HasPrefix(name, "#") && len(name) > 0 { filtered = append(filtered, name) } }