fun findLastSwitchCommit()

in bunch-cli/src/main/kotlin/org/jetbrains/bunches/switch.kt [348:358]


fun findLastSwitchCommit(repoPath: String): CommitInfo? {
    val lastCommits = readCommits(repoPath, true) { this.setMaxCount(checkingCommitCount) }
    val switchCommitsRegex = Regex(RESTORE_COMMIT_TITLE.replace("{target}", ".+"))
    for (commit in lastCommits) {
        val title = commit.title ?: continue
        if (title.contains(switchCommitsRegex)) {
            return commit
        }
    }
    return null
}