|
1 | | -case class Version(major: Int, minor: Int, patch: Int) { |
2 | | - def binary: String = s"${major}${minor}" |
3 | | - override def toString: String = s"${major}.${minor}.${patch}" |
| 1 | +case class Version(major: Int, minor: Int) { |
| 2 | + override def toString = s"${major}${minor}" |
4 | 3 | } |
5 | 4 |
|
6 | 5 | object Version { |
7 | | - // the (#.+)? part allows republishing for a new Scala version |
8 | | - private val versionRegex0 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:#.+)?".r |
9 | | - private val versionRegex1 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.+)(?:#.+)?".r |
| 6 | + // `(#.+)?` allows republishing for a new Scala version |
| 7 | + // `|x` allows the sbt 1.7 style ".x" versions |
| 8 | + private val versionRegex0 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+|x)(?:#.+)?".r |
| 9 | + private val versionRegex1 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+|x)-(.+)(?:#.+)?".r |
10 | 10 | private val versionRegex2 = "([0-9]+)\\.([0-9]+)(?:#.+)?".r |
11 | 11 | private val versionRegex3 = "([0-9]+)(?:#.+)?".r |
12 | 12 | def parse(raw: String): Option[Version] = { |
13 | 13 | raw match { |
14 | | - case versionRegex0(major, minor, patch) => |
15 | | - Some(Version(major.toInt, minor.toInt, patch.toInt)) |
16 | | - case versionRegex1(major, minor, patch, _) => |
17 | | - Some(Version(major.toInt, minor.toInt, patch.toInt)) |
| 14 | + case versionRegex0(major, minor, _) => |
| 15 | + Some(Version(major.toInt, minor.toInt)) |
| 16 | + case versionRegex1(major, minor, _, _) => |
| 17 | + Some(Version(major.toInt, minor.toInt)) |
18 | 18 | case versionRegex2(major, minor) => |
19 | | - Some(Version(major.toInt, minor.toInt, 0)) |
| 19 | + Some(Version(major.toInt, minor.toInt)) |
20 | 20 | case versionRegex3(major) => |
21 | | - Some(Version(major.toInt, 0, 0)) |
| 21 | + Some(Version(major.toInt, 0)) |
22 | 22 | case _ => |
23 | 23 | None |
24 | 24 | } |
|
0 commit comments