diff --git a/build.sbt b/build.sbt index 612e214..a22b24e 100644 --- a/build.sbt +++ b/build.sbt @@ -7,7 +7,7 @@ lazy val root = (project in file(".")) majorVersion := 5, isPublicArtefact := true, scalaVersion := "2.12.18", - crossSbtVersions := Vector("1.9.7"), + crossSbtVersions := Vector("1.9.9"), libraryDependencies ++= Seq( "com.lihaoyi" %% "fansi" % "0.4.0", "com.typesafe.play" %% "play-json" % "2.9.4", diff --git a/src/main/scala/uk/gov/hmrc/bobby/Bobby.scala b/src/main/scala/uk/gov/hmrc/bobby/Bobby.scala index 751964b..c157f8c 100644 --- a/src/main/scala/uk/gov/hmrc/bobby/Bobby.scala +++ b/src/main/scala/uk/gov/hmrc/bobby/Bobby.scala @@ -43,7 +43,7 @@ object Bobby { |""".stripMargin def validateDependencies( - rootName : String, + repoName : String, projectName : String, dependencyDotFiles : Seq[DotFile], internalModuleNodes: Seq[ModuleID], @@ -58,7 +58,7 @@ object Bobby { val messages = dependencyDotFiles.flatMap { dotFile => - val messages = BobbyValidator.validate(dotFile.content, dotFile.scope, bobbyRules, internalModuleNodes, rootName) + val messages = BobbyValidator.validate(dotFile.content, dotFile.scope, bobbyRules, internalModuleNodes, repoName) val outputFileName = s"bobby-report-$projectName-${dotFile.scope}" diff --git a/src/main/scala/uk/gov/hmrc/bobby/SbtBobbyPlugin.scala b/src/main/scala/uk/gov/hmrc/bobby/SbtBobbyPlugin.scala index 668639a..f45e383 100644 --- a/src/main/scala/uk/gov/hmrc/bobby/SbtBobbyPlugin.scala +++ b/src/main/scala/uk/gov/hmrc/bobby/SbtBobbyPlugin.scala @@ -48,8 +48,12 @@ object SbtBobbyPlugin extends AutoPlugin { val projectName = name.value val logger = sLog.value - val pwd = {import scala.sys.process._; "pwd" !!}.trim - val rootName = pwd.split("/").last + val pwd = {import scala.sys.process._; "pwd" !!}.trim + val repoName = (for { + gitUrl <- sys.env.get("GIT_URL") + m <- ".*\\/(.*).git".r.findFirstMatchIn(gitUrl) + } yield m.group(1) + ).getOrElse(pwd.split("/").last) // Retrieve config settings val bobbyConfigFile: ConfigFile = @@ -95,7 +99,7 @@ object SbtBobbyPlugin extends AutoPlugin { } Bobby.validateDependencies( - rootName, + repoName, projectName, dependencyDotFiles, internalModuleNodes, diff --git a/src/main/scala/uk/gov/hmrc/bobby/domain/BobbyValidator.scala b/src/main/scala/uk/gov/hmrc/bobby/domain/BobbyValidator.scala index db78143..41f8a7f 100644 --- a/src/main/scala/uk/gov/hmrc/bobby/domain/BobbyValidator.scala +++ b/src/main/scala/uk/gov/hmrc/bobby/domain/BobbyValidator.scala @@ -28,7 +28,7 @@ object BobbyValidator { scope : String, bobbyRules : Seq[BobbyRule], internalModuleNodes: Seq[ModuleID], - rootName : String + repoName : String ): Seq[Message] = { val graph = DependencyGraphParser.parse(graphString) val dependencies = graph.dependencies @@ -39,7 +39,7 @@ object BobbyValidator { } dependencies.map { dependency => - val result = BobbyValidator.calc(bobbyRules, dependency.toModuleID, rootName) + val result = BobbyValidator.calc(bobbyRules, dependency.toModuleID, repoName) Message( moduleID = dependency.toModuleID, @@ -58,7 +58,7 @@ object BobbyValidator { def calc( bobbyRules : Seq[BobbyRule], dep : ModuleID, - rootName : String, + repoName : String, now : LocalDate = LocalDate.now() ): BobbyResult = { val version = @@ -75,7 +75,7 @@ object BobbyValidator { matchingRules .map { rule => - if (rule.exemptProjects.contains(rootName)) + if (rule.exemptProjects.contains(repoName)) BobbyResult.Exemption(rule): BobbyResult else if (rule.effectiveDate.isBefore(now) || rule.effectiveDate.isEqual(now)) BobbyResult.Violation(rule)