Fix updatalbe packages count #373

This commit is contained in:
Kota Kanbe
2017-03-07 13:49:25 +09:00
parent 41f99f2b65
commit 732d95098a
2 changed files with 11 additions and 9 deletions

View File

@@ -445,16 +445,18 @@ func (ps PackageInfoList) MergeNewVersion(as PackageInfoList) {
func (ps PackageInfoList) countUpdatablePacks() int {
count := 0
set := make(map[string]bool)
for _, p := range ps {
if len(p.NewVersion) != 0 {
if len(p.NewVersion) != 0 && !set[p.Name] {
count++
set[p.Name] = true
}
}
return count
}
// ToUpdatablePacksSummary returns a summary of updatable packages
func (ps PackageInfoList) ToUpdatablePacksSummary() string {
// FormatUpdatablePacksSummary returns a summary of updatable packages
func (ps PackageInfoList) FormatUpdatablePacksSummary() string {
return fmt.Sprintf("%d updatable packages",
ps.countUpdatablePacks())
}