com.avito.impact.configuration.Branches.kt Maven / Gradle / Ivy
The newest version!
package com.avito.impact.configuration
import io.github.azagniotov.matcher.AntPathMatcher
internal fun isBranchProtected(branch: String, protectedBranches: Set): Boolean {
require(branch.isNotBlank()) { "trying to check empty branch" }
return if (protectedBranches.isEmpty()) {
false
} else {
protectedBranches.any { pattern ->
require(pattern.isNotBlank()) { "protectedBranches pattern for $branch must non-empty" }
val patternMatcher = AntPathMatcher.Builder()
.withIgnoreCase()
.withPathSeparator('/')
.build()
patternMatcher.isMatch(pattern, branch)
}
}
}