From 7246f55ce9ac6bd55d15e74c411c237889b91e27 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sun, 17 Sep 2017 22:37:07 -0700 Subject: [PATCH 1/4] fix a bug in Rule.merge --- .../shared/src/main/scala/scalafix/rule/Rule.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scalafix-core/shared/src/main/scala/scalafix/rule/Rule.scala b/scalafix-core/shared/src/main/scala/scalafix/rule/Rule.scala index 144f52a01..c62b7f4c8 100644 --- a/scalafix-core/shared/src/main/scala/scalafix/rule/Rule.scala +++ b/scalafix-core/shared/src/main/scala/scalafix/rule/Rule.scala @@ -186,13 +186,13 @@ object Rule { /** Combine two rules into a single rule */ def merge(a: Rule, b: Rule): Rule = (a, b) match { - case (c1: CompositeRule, c2: CompositeRule) => - new CompositeRule(c1.rules ::: c2.rules) - case (c1: CompositeRule, _) => - new CompositeRule(b :: c1.rules) - case (_, c2: CompositeRule) => - new CompositeRule(b :: c2.rules) - case (_, _) => + case (ac: CompositeRule, bc: CompositeRule) => + new CompositeRule(ac.rules ::: bc.rules) + case (ac: CompositeRule, b) => + new CompositeRule(b :: ac.rules) + case (a, bc: CompositeRule) => + new CompositeRule(a :: bc.rules) + case (a, b) => new CompositeRule(a :: b :: Nil) } } From acce3b9a4d0860f0265c482ee204dc31f4dba503 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sun, 17 Sep 2017 22:46:17 -0700 Subject: [PATCH 2/4] support for custom repositories and credentials --- build.sbt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index be942a390..8e3c7c36a 100644 --- a/build.sbt +++ b/build.sbt @@ -33,9 +33,20 @@ commands += Command.command("ci-slow") { s => s } +lazy val adhocRepoUri = sys.props("scalafix.repository.uri") +lazy val adhocRepoCredentials = sys.props("scalafix.repository.credentials") +lazy val isCustomRepository = adhocRepoUri != null && adhocRepoCredentials != null + lazy val publishSettings = Seq( - publishTo := Some( - "releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"), + publishTo := { + if (isCustomRepository) Some("adhoc" at adhocRepoUri) + else Some("Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") + }, + credentials ++= { + val credentialsFile = if (adhocRepoCredentials != null) new File(adhocRepoCredentials) else null + if (credentialsFile != null) List(new FileCredentials(credentialsFile)) + else Nil + }, publishArtifact in Test := false, licenses := Seq( "Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), From 114a1902d3888ebbdd4be65423b6d413df82625a Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sun, 17 Sep 2017 23:22:35 -0700 Subject: [PATCH 3/4] avoid + in version number This confuses the toolchain to the degree when `coursier bootstrap` succeeds, but `scalafix -r file:foo/bar/Baz.scala` fails. --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8e3c7c36a..b84a6a5f0 100644 --- a/build.sbt +++ b/build.sbt @@ -6,7 +6,7 @@ import Dependencies._ inThisBuild( List( organization := "ch.epfl.scala", - version := customScalafixVersion.getOrElse(version.value) + version := customScalafixVersion.getOrElse(version.value.replace('+', '-')) ) ) name := { From 3df0d6daee7121379b265e7750a1122b00e8538c Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 18 Sep 2017 10:42:40 -0700 Subject: [PATCH 4/4] reformat with scalafmt --- build.sbt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index b84a6a5f0..b39bc29eb 100644 --- a/build.sbt +++ b/build.sbt @@ -40,10 +40,16 @@ lazy val isCustomRepository = adhocRepoUri != null && adhocRepoCredentials != nu lazy val publishSettings = Seq( publishTo := { if (isCustomRepository) Some("adhoc" at adhocRepoUri) - else Some("Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") + else { + val uri = "https://oss.sonatype.org/service/local/staging/deploy/maven2" + Some("Releases" at uri) + } }, credentials ++= { - val credentialsFile = if (adhocRepoCredentials != null) new File(adhocRepoCredentials) else null + val credentialsFile = { + if (adhocRepoCredentials != null) new File(adhocRepoCredentials) + else null + } if (credentialsFile != null) List(new FileCredentials(credentialsFile)) else Nil },