MCPcopy Create free account
hub / github.com/jetify-com/devbox / latestPackages

Function latestPackages

internal/boxcli/multi/sync.go:68–94  ·  view source on GitHub ↗
(lockfilePaths []string)

Source from the content-addressed store, hash-verified

66}
67
68func 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
96func collectLockfiles() ([]string, error) {
97 defer debug.FunctionTimer().End()

Callers 1

SyncLockfilesFunction · 0.85

Calls 1

ParseFileFunction · 0.92

Tested by

no test coverage detected