fun checkOneCommit()

in bunch-cli/src/main/kotlin/org/jetbrains/bunches/check.kt [114:140]


fun checkOneCommit(
    commit: CommitInfo,
    extensions: List<String>,
    directory: String,
    createFileCommitIndex: Map<String, Int>,
    commitIndex: Int
): List<String> {
    val affectedPaths = commit.fileActions.mapNotNullTo(HashSet()) { it.newPath }

    val forgottenFilesPaths = mutableListOf<String>()
    for (fileAction in commit.fileActions) {
        val newPath = fileAction.newPath ?: continue
        if (File(newPath).extension in extensions) continue

        for (extension in extensions) {
            val bunchFilePath = "$newPath.$extension"
            val file = File(directory, bunchFilePath)
            if (bunchFilePath !in affectedPaths
                && file.exists()
                && isCreatedBefore(createFileCommitIndex[bunchFilePath], commitIndex)
            ) {
                forgottenFilesPaths.add(bunchFilePath)
            }
        }
    }
    return forgottenFilesPaths
}