Remove Kotlin interactive-add emulation and run patch add via the native Git runtime with PTY-backed session IO.
76 lines
2.1 KiB
Kotlin
76 lines
2.1 KiB
Kotlin
package solutions.tretter.githugandroid
|
|
|
|
|
|
enum class PlayMode(val label: String) {
|
|
CLI_ONLY("CLI ONLY"),
|
|
VISUAL("VISUAL"),
|
|
}
|
|
|
|
data class GitFile(
|
|
val name: String,
|
|
val content: String = "",
|
|
val staged: Boolean = false,
|
|
val tracked: Boolean = false,
|
|
val deleted: Boolean = false,
|
|
val stagedContent: String? = null,
|
|
)
|
|
|
|
data class CommitNode(
|
|
val id: String,
|
|
val message: String,
|
|
val authorTimestampSeconds: Long? = null,
|
|
val parentCount: Int = 0,
|
|
)
|
|
|
|
data class NativeGitSession(
|
|
val id: Int,
|
|
val command: String,
|
|
)
|
|
|
|
data class RepoState(
|
|
val initialized: Boolean = false,
|
|
val files: List<GitFile> = emptyList(),
|
|
val commits: List<CommitNode> = emptyList(),
|
|
val headBranch: String = "master",
|
|
val branches: Map<String, Int> = emptyMap(),
|
|
val currentDir: String = ".",
|
|
val tags: List<String> = emptyList(),
|
|
val remotes: Map<String, String> = emptyMap(),
|
|
val config: Map<String, String> = emptyMap(),
|
|
val stashes: List<String> = emptyList(),
|
|
val fetchedBranches: Set<String> = emptySet(),
|
|
val fetchHeadCount: Int = 0,
|
|
val pushedBranches: Set<String> = emptySet(),
|
|
val pushedTags: Set<String> = emptySet(),
|
|
val submodules: Map<String, String> = emptyMap(),
|
|
val maintenanceActions: Set<String> = emptySet(),
|
|
val nativeGitSession: NativeGitSession? = null,
|
|
)
|
|
|
|
data class Level(
|
|
val id: String,
|
|
val title: String,
|
|
val description: String,
|
|
val hints: List<String>,
|
|
val commandSuggestions: List<String>,
|
|
val validator: (RepoState, String) -> Boolean,
|
|
val setup: () -> RepoState,
|
|
val nativeSetup: (NativeLevelSetup.() -> Boolean)? = null,
|
|
val testCases: List<LevelTestCase> = emptyList(),
|
|
val negativeTestCases: List<LevelTestCase> = emptyList(),
|
|
val setupChecks: List<LevelSetupCheck> = emptyList(),
|
|
)
|
|
|
|
data class LevelTestCase(
|
|
val name: String,
|
|
val commands: List<String>,
|
|
)
|
|
|
|
data class LevelSetupCheck(
|
|
val name: String,
|
|
val failureMessage: String,
|
|
val predicate: (RepoState) -> Boolean,
|
|
)
|
|
|
|
fun sampleLevels(): List<Level> = allGithugLevels()
|