Skip to content

minor code improvement in build #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2019
Merged
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
16 changes: 8 additions & 8 deletions project/Version.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ case class Version(major: Int, minor: Int, patch: Int) {

object Version {
// the (#.+)? part allows republishing for a new Scala version
private val versionRegex0 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)(#.+)?".r
private val versionRegex1 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.+)(#.+)?".r
private val versionRegex2 = "([0-9]+)\\.([0-9]+)(#.+)?".r
private val versionRegex3 = "([0-9]+)(#.+)?".r
private val versionRegex0 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:#.+)?".r
private val versionRegex1 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-(.+)(?:#.+)?".r
private val versionRegex2 = "([0-9]+)\\.([0-9]+)(?:#.+)?".r
private val versionRegex3 = "([0-9]+)(?:#.+)?".r
def parse(raw: String): Option[Version] = {
raw match {
case versionRegex0(major, minor, patch, _) =>
case versionRegex0(major, minor, patch) =>
Some(Version(major.toInt, minor.toInt, patch.toInt))
case versionRegex1(major, minor, patch, _, _) =>
case versionRegex1(major, minor, patch, _) =>
Some(Version(major.toInt, minor.toInt, patch.toInt))
case versionRegex2(major, minor, _) =>
case versionRegex2(major, minor) =>
Some(Version(major.toInt, minor.toInt, 0))
case versionRegex3(major, _) =>
case versionRegex3(major) =>
Some(Version(major.toInt, 0, 0))
case _ =>
None
Expand Down