All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.specmatic.core.utilities.GitMonoRepo.kt Maven / Gradle / Ivy

Go to download

Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends.

There is a newer version: 2.0.37
Show newest version
package io.specmatic.core.utilities

import io.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
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy