in.specmatic.core.utilities.GitMonoRepo.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of specmatic-core Show documentation
Show all versions of specmatic-core Show documentation
Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends.
Deprecation Notice for group ID "in.specmatic"
******************************************************************************************************
Updates for "specmatic-core" will no longer be available under the deprecated group ID "in.specmatic".
Please update your dependencies to use the new group ID "io.specmatic".
******************************************************************************************************
package `in`.specmatic.core.utilities
import `in`.specmatic.core.git.SystemGit
import java.io.File
data class GitMonoRepo(override val testContracts: List, override val stubContracts: List,
override val type: String?) : ContractSource, GitSource {
override fun pathDescriptor(path: String): String = path
override fun install(workingDirectory: File) {
println("Checking list of mono repo paths...")
val contracts = testContracts + stubContracts
for (path in contracts) {
val existenceMessage = when {
File(path).exists() -> "$path exists"
else -> "$path NOT FOUND!"
}
println(existenceMessage)
}
}
override fun directoryRelativeTo(workingDirectory: File) = workingDirectory.resolve(gitRootDir())
override fun getLatest(sourceGit: SystemGit) {
// In mono repos, we can't pull latest arbitrarily
}
override fun pushUpdates(sourceGit: SystemGit) {
// In mono repos, we can't push arbitrarily
}
override fun loadContracts(selector: ContractsSelectorPredicate, workingDirectory: String, configFilePath: String): List {
val monoRepoBaseDir = File(SystemGit().gitRoot())
val configFileLocation = File(configFilePath).absoluteFile.parentFile
return selector.select(this).map {
ContractPathData(
monoRepoBaseDir.canonicalPath,
configFileLocation.resolve(it).canonicalPath,
provider = type,
specificationPath = it
)
}
}
}