Skip to content

Commit

Permalink
Merge pull request #107 from bhundven/filter_comments
Browse files Browse the repository at this point in the history
Filter comments in the list file as well as empty lines.
  • Loading branch information
shawnHartsell committed Apr 5, 2024
2 parents 4e43192 + 67d8422 commit 11bc18f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/reponames.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
}
Expand Down

0 comments on commit 11bc18f

Please sign in to comment.