Skip to content

Commit 32687f8

Browse files
authored
minor code improvement in build (scala#213)
1 parent 136daa8 commit 32687f8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

project/Version.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ case class Version(major: Int, minor: Int, patch: Int) {
55

66
object Version {
77
// 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
10-
private val versionRegex2 = "([0-9]+)\\.([0-9]+)(#.+)?".r
11-
private val versionRegex3 = "([0-9]+)(#.+)?".r
8+
private val versionRegex0 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:#.+)?".r
9+
private val versionRegex1 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.+)(?:#.+)?".r
10+
private val versionRegex2 = "([0-9]+)\\.([0-9]+)(?:#.+)?".r
11+
private val versionRegex3 = "([0-9]+)(?:#.+)?".r
1212
def parse(raw: String): Option[Version] = {
1313
raw match {
14-
case versionRegex0(major, minor, patch, _) =>
14+
case versionRegex0(major, minor, patch) =>
1515
Some(Version(major.toInt, minor.toInt, patch.toInt))
16-
case versionRegex1(major, minor, patch, _, _) =>
16+
case versionRegex1(major, minor, patch, _) =>
1717
Some(Version(major.toInt, minor.toInt, patch.toInt))
18-
case versionRegex2(major, minor, _) =>
18+
case versionRegex2(major, minor) =>
1919
Some(Version(major.toInt, minor.toInt, 0))
20-
case versionRegex3(major, _) =>
20+
case versionRegex3(major) =>
2121
Some(Version(major.toInt, 0, 0))
2222
case _ =>
2323
None

0 commit comments

Comments
 (0)