Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
add a BasicStatus channel
Browse files Browse the repository at this point in the history
  • Loading branch information
darkowlzz committed Sep 7, 2017
1 parent 923ed79 commit 2e44075
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,8 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana

logger.Println("Checking upstream projects:")

// A map of ProjectRoot and *BasicStatus. This is used in maintain the
// order of BasicStatus in output by collecting all the BasicStatus and
// then using them in order.
bsMap := make(map[string]*BasicStatus)
// BasicStatus channel
bsCh := make(chan *BasicStatus, len(slp))

var wg sync.WaitGroup

Expand Down Expand Up @@ -447,14 +445,23 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
}
}

bsMap[bs.ProjectRoot] = &bs
bsCh <- &bs

}(proj)
}

wg.Wait()
close(bsCh)
logger.Println()

// A map of ProjectRoot and *BasicStatus. This is used in maintain the
// order of BasicStatus in output by collecting all the BasicStatus and
// then using them in order.
bsMap := make(map[string]*BasicStatus)
for bs := range bsCh {
bsMap[bs.ProjectRoot] = bs
}

// Use the collected BasicStatus in outputter
for _, proj := range slp {
out.BasicLine(bsMap[string(proj.Ident().ProjectRoot)])
Expand Down

0 comments on commit 2e44075

Please sign in to comment.