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

in.specmatic.core.utilities.ContractSource.kt Maven / Gradle / Ivy

Go to download

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". ******************************************************************************************************

There is a newer version: 1.3.39
Show newest version
package `in`.specmatic.core.utilities

import `in`.specmatic.core.git.NonZeroExitError
import `in`.specmatic.core.git.SystemGit
import `in`.specmatic.core.git.exitErrorMessageContains
import java.io.File

sealed interface ContractSource {
    val type:String?
    val testContracts: List
    val stubContracts: List
    fun pathDescriptor(path: String): String
    fun install(workingDirectory: File)
    fun directoryRelativeTo(workingDirectory: File): File
    fun getLatest(sourceGit: SystemGit)
    fun pushUpdates(sourceGit: SystemGit)
    fun loadContracts(selector: ContractsSelectorPredicate, workingDirectory: String, configFilePath: String): List
}

fun commitAndPush(sourceGit: SystemGit) {
    val pushRequired = try {
        sourceGit.commit()
        true
    } catch (e: NonZeroExitError) {
        if (!exitErrorMessageContains(e, listOf("nothing to commit")))
            throw e

        exitErrorMessageContains(e, listOf("branch is ahead of"))
    }

    when {
        pushRequired -> {
            println("Pushing changes")
            sourceGit.push()
        }
        else -> println("No changes were made to the repo, so nothing was pushed.")
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy