Skip to content

Commit

Permalink
Filter comments in the list file as well as empty lines.
Browse files Browse the repository at this point in the history
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 <bryanhundven@gmail.com>
  • Loading branch information
bhundven committed Apr 4, 2024
1 parent 4e43192 commit 67d8422
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 67d8422

Please sign in to comment.