in.specmatic.core.utilities.ContractSource.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.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.")
}
}