Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(246)

Unified Diff: tools/list.go

Issue 25080043: cmd/juju: upgrade-juju minor version upgrades (Closed)
Patch Set: cmd/juju: upgrade-juju minor version upgrades Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cmd/juju/upgradejuju_test.go ('k') | tools/list_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/list.go
=== modified file 'tools/list.go'
--- tools/list.go 2013-09-13 14:48:13 +0000
+++ tools/list.go 2013-11-14 09:07:52 +0000
@@ -85,6 +85,26 @@
return best, result
}
+// NewestCompatible returns the most recent version compatible with
+// base, i.e. with the same major and minor numbers and greater or
+// equal patch and build numbers.
+func (src List) NewestCompatible(base version.Number) (newest version.Number, found bool) {
+ newest = base
+ found = false
+ for _, tool := range src {
+ toolVersion := tool.Version.Number
+ if newest == toolVersion {
+ found = true
+ } else if newest.Less(toolVersion) &&
+ toolVersion.Major == newest.Major &&
+ toolVersion.Minor == newest.Minor {
+ newest = toolVersion
+ found = true
+ }
+ }
+ return newest, found
+}
+
// Difference returns the tools in src that are not in excluded.
func (src List) Exclude(excluded List) List {
ignore := make(map[version.Binary]bool, len(excluded))
« no previous file with comments | « cmd/juju/upgradejuju_test.go ('k') | tools/list_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b