Implementation of all-matches functionality + tests

When performing an *aptly snapshot pull*, users might list dependency
versions that can potentially match multiple packages in the source
snapshot. However, the current implementation of the 'snapshot pull'
command only allows one package to be pulled from a snapshot at a time
for a given dependency.

The newly implemented all-matches flag allows users to pull all the
matching packages from a source snapshot, provided that they satisfy the
version requirements indicated by the dependencies.

The all-matches flag defaults to false and only produces the described
behaviour when it is explicitly set to true.
This commit is contained in:
Simon Aquino
2014-06-27 01:40:41 +01:00
parent 856dd7021c
commit 3cf281965b
7 changed files with 255 additions and 68 deletions
+23
View File
@@ -188,6 +188,29 @@ type Dependency struct {
Architecture string
}
// NextVersion returns the next version of a dependency (eg. if d.Version = 1.9, it returns 1.10)
func (d *Dependency) NextVersion() string {
l := len(d.Version)
if l == 0 {
return ""
}
i := l
for i > 0 {
_, err := strconv.ParseUint(d.Version[i-1:l],10,0)
if err != nil { break }
i--
}
v, err := strconv.ParseUint(d.Version[i:l],10,0)
if err != nil {
return d.Version
}
return d.Version[0:i] + strconv.Itoa(int(v)+1)
}
// Hash calculates some predefined unique ID of Dependency
func (d *Dependency) Hash() string {
return fmt.Sprintf("%s:%s:%d:%s", d.Architecture, d.Pkg, d.Relation, d.Version)