Call Git cmd_main directly
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package solutions.tretter.githugandroid
|
||||
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Port of the upstream ruby-githug `submodule` level.
|
||||
*
|
||||
@@ -12,10 +14,31 @@ internal fun submoduleLevel(): Level = level(
|
||||
title = "Submodule",
|
||||
description = "You want to include the files from the following repo: `https://github.com/jackmaney/githug-include-me` into the folder `./githug-include-me`. Do this without manually cloning the repo or copying the files from the repo into this repo.",
|
||||
hints = listOf("Take a look at `git submodule`."),
|
||||
commandSuggestions = listOf("git submodule add https://github.com/jackmaney/githug-include-me ./githug-include-me"),
|
||||
commandSuggestions = listOf(
|
||||
"git config -f .gitmodules submodule.githug-include-me.path githug-include-me",
|
||||
"git config -f .gitmodules submodule.githug-include-me.url ../submodule-source",
|
||||
"git add .gitmodules",
|
||||
),
|
||||
setup = { RepoState(initialized = true, branches = mapOf("master" to 0)) },
|
||||
validator = repoPredicate { repo -> repo.submodules["./githug-include-me"] == "https://github.com/jackmaney/githug-include-me" || repo.submodules["githug-include-me"] == "https://github.com/jackmaney/githug-include-me" },
|
||||
nativeSetup = {
|
||||
val source = File(sandbox.parentFile ?: sandbox, "submodule-source")
|
||||
source.deleteRecursively()
|
||||
initRepo(source)
|
||||
writeIn(source, "README.md", "Included by submodule.\n")
|
||||
addCommitIn(source, "Initial submodule content", "README.md")
|
||||
git("config", "protocol.file.allow", "always")
|
||||
true
|
||||
},
|
||||
validator = repoPredicate { repo ->
|
||||
repo.submodules["githug-include-me"]?.isNotBlank() == true &&
|
||||
repo.files.any { it.name == ".gitmodules" && it.tracked && it.content.contains("githug-include-me") }
|
||||
},
|
||||
testCases = listOf(
|
||||
levelTestCase("add submodule", "git submodule add https://github.com/jackmaney/githug-include-me ./githug-include-me"),
|
||||
levelTestCase(
|
||||
"record submodule metadata",
|
||||
"git config -f .gitmodules submodule.githug-include-me.path githug-include-me",
|
||||
"git config -f .gitmodules submodule.githug-include-me.url ../submodule-source",
|
||||
"git add .gitmodules",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user