(lockfilePaths []string)
| 66 | } |
| 67 | |
| 68 | func latestPackages(lockfilePaths []string) (map[string]*lock.Package, error) { |
| 69 | latestPackages := make(map[string]*lock.Package) |
| 70 | |
| 71 | for _, lockFilePath := range lockfilePaths { |
| 72 | var lockFile lock.File |
| 73 | if err := cuecfg.ParseFile(lockFilePath, &lockFile); err != nil { |
| 74 | return nil, err |
| 75 | } |
| 76 | for key, pkg := range lockFile.Packages { |
| 77 | if latestPkg, exists := latestPackages[key]; exists { |
| 78 | // Ignore error, which makes currentTime.After always false. |
| 79 | currentTime, _ := time.Parse(time.RFC3339, pkg.LastModified) |
| 80 | latestTime, err := time.Parse(time.RFC3339, latestPkg.LastModified) |
| 81 | if err != nil { |
| 82 | return nil, err |
| 83 | } |
| 84 | if currentTime.After(latestTime) { |
| 85 | latestPackages[key] = pkg |
| 86 | } |
| 87 | } else if _, err := time.Parse(time.RFC3339, pkg.LastModified); err == nil { |
| 88 | latestPackages[key] = pkg |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return latestPackages, nil |
| 94 | } |
| 95 | |
| 96 | func collectLockfiles() ([]string, error) { |
| 97 | defer debug.FunctionTimer().End() |
no test coverage detected