Skip to content

Commit 136daa8

Browse files
authored
Merge pull request #212 from SethTisue/allow-republishing
allow republishing for new Scala versions
2 parents 23fde69 + 35a0219 commit 136daa8

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

project/Version.scala

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

66
object Version {
7-
private val versionRegex0 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)".r
8-
private val versionRegex1 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.+)".r
9-
private val versionRegex2 = "([0-9]+)\\.([0-9]+)".r
10-
private val versionRegex3 = "([0-9]+)".r
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
10+
private val versionRegex2 = "([0-9]+)\\.([0-9]+)(#.+)?".r
11+
private val versionRegex3 = "([0-9]+)(#.+)?".r
1112
def parse(raw: String): Option[Version] = {
1213
raw match {
13-
case versionRegex0(major, minor, patch) =>
14+
case versionRegex0(major, minor, patch, _) =>
1415
Some(Version(major.toInt, minor.toInt, patch.toInt))
15-
case versionRegex1(major, minor, patch, _) =>
16+
case versionRegex1(major, minor, patch, _, _) =>
1617
Some(Version(major.toInt, minor.toInt, patch.toInt))
17-
case versionRegex2(major, minor) =>
18+
case versionRegex2(major, minor, _) =>
1819
Some(Version(major.toInt, minor.toInt, 0))
19-
case versionRegex3(major) =>
20+
case versionRegex3(major, _) =>
2021
Some(Version(major.toInt, 0, 0))
2122
case _ =>
2223
None

0 commit comments

Comments
 (0)