Skip to content

Commit

Permalink
BDOG-3159 Correct repoName lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-lamed committed Jun 5, 2024
1 parent c17eb6a commit ddad5fa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/uk/gov/hmrc/bobby/Bobby.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object Bobby {
|""".stripMargin

def validateDependencies(
rootName : String,
repoName : String,
projectName : String,
dependencyDotFiles : Seq[DotFile],
internalModuleNodes: Seq[ModuleID],
Expand All @@ -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}"

Expand Down
10 changes: 7 additions & 3 deletions src/main/scala/uk/gov/hmrc/bobby/SbtBobbyPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -95,7 +99,7 @@ object SbtBobbyPlugin extends AutoPlugin {
}

Bobby.validateDependencies(
rootName,
repoName,
projectName,
dependencyDotFiles,
internalModuleNodes,
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/uk/gov/hmrc/bobby/domain/BobbyValidator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -58,7 +58,7 @@ object BobbyValidator {
def calc(
bobbyRules : Seq[BobbyRule],
dep : ModuleID,
rootName : String,
repoName : String,
now : LocalDate = LocalDate.now()
): BobbyResult = {
val version =
Expand All @@ -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)
Expand Down

0 comments on commit ddad5fa

Please sign in to comment.