Require real merge commit and keep level tests embedded
This commit is contained in:
@@ -8,7 +8,14 @@ val RepoStateSaver = listSaver<RepoState, Any>(
|
||||
state.initialized,
|
||||
state.headBranch,
|
||||
state.files.flatMap { listOf(it.name, it.content, it.staged.toString(), it.tracked.toString(), it.deleted.toString()) },
|
||||
state.commits.flatMap { listOf(it.id, it.message, it.authorTimestampSeconds?.toString().orEmpty()) },
|
||||
state.commits.flatMap {
|
||||
listOf(
|
||||
it.id,
|
||||
it.message,
|
||||
it.authorTimestampSeconds?.toString().orEmpty(),
|
||||
it.parentCount.toString(),
|
||||
)
|
||||
},
|
||||
state.branches.flatMap { listOf(it.key, it.value.toString()) },
|
||||
state.currentDir,
|
||||
state.tags,
|
||||
@@ -86,11 +93,21 @@ val RepoStateSaver = listSaver<RepoState, Any>(
|
||||
)
|
||||
|
||||
private fun List<*>.restoreCommitNodes(): List<CommitNode> {
|
||||
val hasTimestampColumn = size % 3 == 0 && chunked(3).all { chunk ->
|
||||
val hasTimestampAndParentColumns = size % 4 == 0 && chunked(4).all { chunk ->
|
||||
val timestamp = chunk.getOrNull(2) as? String
|
||||
val parentCount = chunk.getOrNull(3) as? String
|
||||
(timestamp.isNullOrEmpty() || timestamp.toLongOrNull()?.let { it >= 100_000_000L } == true) &&
|
||||
parentCount?.toIntOrNull() != null
|
||||
}
|
||||
val hasTimestampColumn = !hasTimestampAndParentColumns && size % 3 == 0 && chunked(3).all { chunk ->
|
||||
val timestamp = chunk.getOrNull(2) as? String
|
||||
timestamp.isNullOrEmpty() || timestamp.toLongOrNull()?.let { it >= 100_000_000L } == true
|
||||
}
|
||||
val width = if (hasTimestampColumn) 3 else 2
|
||||
val width = when {
|
||||
hasTimestampAndParentColumns -> 4
|
||||
hasTimestampColumn -> 3
|
||||
else -> 2
|
||||
}
|
||||
|
||||
return chunked(width).mapNotNull { chunk ->
|
||||
val id = chunk.getOrNull(0) as? String ?: return@mapNotNull null
|
||||
@@ -98,7 +115,12 @@ private fun List<*>.restoreCommitNodes(): List<CommitNode> {
|
||||
CommitNode(
|
||||
id = id,
|
||||
message = message,
|
||||
authorTimestampSeconds = if (hasTimestampColumn) (chunk.getOrNull(2) as? String)?.toLongOrNull() else null,
|
||||
authorTimestampSeconds = if (hasTimestampAndParentColumns || hasTimestampColumn) {
|
||||
(chunk.getOrNull(2) as? String)?.toLongOrNull()
|
||||
} else {
|
||||
null
|
||||
},
|
||||
parentCount = if (hasTimestampAndParentColumns) (chunk.getOrNull(3) as? String)?.toIntOrNull() ?: 0 else 0,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user