Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@ List of contributors, in chronological order:
* JupiterRider (https://github.com/JupiterRider)
* Agustin Henze (https://github.com/agustinhenze)
* Tobias Assarsson (https://github.com/daedaluz)
* Yaksh Bariya (https://github.com/thunder-coding)
* Juan Calderon-Perez (https://github.com/gaby)
* Ato Araki (https://github.com/atotto)
8 changes: 4 additions & 4 deletions deb/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ func CompareVersions(ver1, ver2 string) int {

// parseVersions breaks down full version to components (possibly empty)
func parseVersion(ver string) (epoch, upstream, debian string) {
i := strings.LastIndex(ver, "-")
i := strings.Index(ver, ":")
if i != -1 {
debian, ver = ver[i+1:], ver[:i]
epoch, ver = ver[:i], ver[i+1:]
}

i = strings.Index(ver, ":")
i = strings.Index(ver, "-")
if i != -1 {
epoch, ver = ver[:i], ver[i+1:]
debian, ver = ver[i+1:], ver[:i]
}

upstream = ver
Expand Down
5 changes: 3 additions & 2 deletions deb/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func (s *VersionSuite) TestParseVersion(c *C) {
c.Check([]string{e, u, d}, DeepEquals, []string{"", "1.3.4", "1"})

e, u, d = parseVersion("1.3-pre4-1")
c.Check([]string{e, u, d}, DeepEquals, []string{"", "1.3-pre4", "1"})
c.Check([]string{e, u, d}, DeepEquals, []string{"", "1.3", "pre4-1"})

e, u, d = parseVersion("4:1.3-pre4-1")
c.Check([]string{e, u, d}, DeepEquals, []string{"4", "1.3-pre4", "1"})
c.Check([]string{e, u, d}, DeepEquals, []string{"4", "1.3", "pre4-1"})
}

func (s *VersionSuite) TestCompareLexicographic(c *C) {
Expand Down Expand Up @@ -100,6 +100,7 @@ func (s *VersionSuite) TestCompareVersions(c *C) {
c.Check(CompareVersions("1.0-133-avc", "1.0"), Equals, 1)

c.Check(CompareVersions("5.2.0.3", "5.2.0.283"), Equals, -1)
c.Check(CompareVersions("4.3.5a", "4.3.5-rc3-1"), Equals, 1)
}

func (s *VersionSuite) TestParseDependency(c *C) {
Expand Down
Loading