Skip to content

Commit

Permalink
Fix lock file parsing for Bazel 7.2.0 (#397)
Browse files Browse the repository at this point in the history
Fixes #396
  • Loading branch information
hb-man authored Jul 16, 2024
1 parent c08ac30 commit e04636d
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ class BzlModDataExtractor(

private fun findRepositories(): List<String> {
val lockFile = workspaceRoot.resolve("MODULE.bazel.lock")
val defaultRepo = "https://bcr.bazel.build"
val repositories = if (lockFile.exists()) {
jsonReader.readTree(lockFile.toFile()).path("flags").path("cmdRegistries").map { it.asText() }
val jsonNode = jsonReader.readTree(lockFile.toFile())
val cmdRegistries = jsonNode.path("flags").path("cmdRegistries")
if (cmdRegistries.isArray && !cmdRegistries.isEmpty) {
cmdRegistries.map { it.asText() }
} else {
listOf(defaultRepo)
}
} else {
listOf("https://bcr.bazel.build")
listOf(defaultRepo)
}
return repositories.map { it.removeSuffix("/") }
}
Expand Down

0 comments on commit e04636d

Please sign in to comment.