Skip to content

Commit

Permalink
added guard clause instead of extra loop
Browse files Browse the repository at this point in the history
  • Loading branch information
physcrowley committed Nov 9, 2023
1 parent c3f0077 commit 4e5483f
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions cmd/gh-classroom/pull/student-repos/student-repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,15 @@ func NewCmdStudentReposPull(f *cmdutil.Factory) *cobra.Command {
log.Fatal(err)
}

all_entries, err := os.ReadDir(fullPath)
entries, err := os.ReadDir(fullPath)
if err != nil {
log.Fatal(err)
}

//filter entries to only directories
var entries []os.DirEntry
for _, r := range all_entries {
if r.IsDir() {
entries = append(entries, r)
}
}

for _, r := range entries {
if !r.IsDir() {
continue
}
clonePath := filepath.Join(fullPath, r.Name())
fmt.Printf("Pulling repo: %v\n", clonePath)
err = os.Chdir(clonePath)
Expand Down

0 comments on commit 4e5483f

Please sign in to comment.