mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user